no warning on missing constructor

For other topics related to the FreeBASIC project or its community.
srvaldez
Posts: 1834
Joined: Sep 25, 2005 21:54

no warning on missing constructor

Postby srvaldez » Mar 01, 2018 15:36

I post here because I don't have a small code example to show the problem.
just for fun I put together some code to use the extended precision of libm, I declared constructors in the type definition but forgot to implement one of the constructors.
some tests compiled and run ok without warning until I tried to run a larger example where the constructor was called, I got this message

Code: Select all

Undefined symbols for architecture x86_64:
  "__ZN11CLONGDOUBLEC1Ed", referenced from:
      _main in example.o
ld: symbol(s) not found for architecture x86_64
Compilation failed.

it would be nice to receive a warning of the missing constructor.
TeeEmCee
Posts: 243
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: no warning on missing constructor

Postby TeeEmCee » Mar 01, 2018 20:55

I don't see the problem. Not defining a constructor is a link-time error. It can't be caught while compiling any individual .bas file, because it could be defined in any other .bas file. So fbc can't print an error message, but the linker did.

Although, it's strange that ld didn't demangle the symbol name. According to the man page, the --demangle option is on by default. Maybe a particular demangling style needs to be specified? Or is it possible it's the GOLD linker? GOLD has the same option, but doesn't say whether it's on by default.
srvaldez
Posts: 1834
Joined: Sep 25, 2005 21:54

Re: no warning on missing constructor

Postby srvaldez » Mar 01, 2018 23:15

the problem is that it's not obvious where the problem is, now if the symbol reported by ld was un-mangled then it would be easier hunt the bug.
TeeEmCee
Posts: 243
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: no warning on missing constructor

Postby TeeEmCee » Mar 02, 2018 2:08

What OS are you using? I assume Windows, because there's an extra leading underscore on the symbol name.
If you pass "-Wl --demangle" to fbc when compiling, does it demangle the name? What about "-Wl --demangle=gnu"?
srvaldez
Posts: 1834
Joined: Sep 25, 2005 21:54

Re: no warning on missing constructor

Postby srvaldez » Mar 02, 2018 3:25

TeeEmCee wrote:What OS are you using? I assume Windows

no, this is on OS X, my apologies, I should have given that information in my first post, as for the command line options you gave, ld reports that they are unknown.
TeeEmCee
Posts: 243
Joined: Jul 22, 2006 0:54
Location: Auckland

Re: no warning on missing constructor

Postby TeeEmCee » Mar 03, 2018 2:47

Oh, well that explains it. OSX's ld is an ancient fork of BSD ld, and doesn't demangle symbols. FreeBSD, NetBSD, OpenBSD, Linux, Mingw/Windows all use the GNU linker, which demangles symbols. GNU ld and GNU gold don't even support OSX last I checked, because it's very peculiar. You're out of luck.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest