[llvm-bugs] [Bug 27853] incompatibility w/gcc re: ODR, template instantiation, optimization across translation units

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 25 15:54:06 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27853

Richard Smith <richard-llvm at metafoo.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |richard-llvm at metafoo.co.uk
         Resolution|---                         |INVALID

--- Comment #20 from Richard Smith <richard-llvm at metafoo.co.uk> ---
(In reply to comment #19)
> (In reply to comment #17)
> > Both compilers are probably discarding 'obj' because it is unused.
> 
> But it *is* being used -- in doTest1 and doTest2.  So, I don't think that
> statement is correct.  

It's unused *in the generated code*.

> But I *thought* that statics (including local statics) were required to
> exist in the .bss section of the shared library/executable.

Some symbols are required to be emitted by every translation unit that needs a
definition of them (after optimization). Those ones are not guaranteed to exist
anywhere in the optimized object code.

If you want to find symbols via dlsym, you need to avoid that kind. The usual
approach to this is to make the symbols external linkage, extern "C", and
marked with __attribute__((used)). That guarantees their existence and that
they have a non-mangled name.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160525/3eec60a5/attachment.html>


More information about the llvm-bugs mailing list