No, it shouldn't - clang attempts to avoid emitting duplicate debug info
across the program (it assumes you built the whole program and all
libraries with debug info), gcc assumes the same thing though in slightly
different/fewer ways.
The solution is to install the -dbg build of your libstdc++ package
(assuming you're using libstdc++), it will include debug info for the
standard library, including std::string.

To see a case where GCC does the same thing - try a variable of type
std::fstream. GCC, similarly, will produce only a declaration for the
basic_fstream type, not the definition.

(& here's a lightning talk that discusses, briefly, some of this:
https://www.youtube.com/watch?v=XvkLHIASlp8 )

On Thu, Jul 25, 2019 at 11:41 AM Bob Eastbrook via cfe-users <
cfe-users@lists.llvm.org> wrote:

> On Fedora 30, "clang++ -g main.cc" does not emit debugging information
> for types such as std::string.  I can only get complete debugging
> information by including "-fno-limit-debug-info".
>
> On Ubuntu 19.04, "clang++ -g" emits debugging info for std::string as
> expected.
>
> Which behavior of "-g" is correct?  Can anyone explain why each
> platform behaves differently?
> _______________________________________________
> cfe-users mailing list
> cfe-users@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to