This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [C++ PATCH] Diagnose static data members in anon ns which are used, but weren't defined (PR c++/34094)


Jakub Jelinek wrote:
Before the visibility changes for anon namespaces if a static data member
wasn't defined (just declared), but used, there would be a link time
failure.  But as constrain_visibility (decl, VISIBILITY_ANON) makes
now the static data members !TREE_PUBLIC and DECL_NOR_REALLY_EXTERN,
even when they are not defined g++ emits them in .bss.

That seems like the bug. Why are we emitting a definition of something which hasn't been defined?


I'm not sure whether the && DECL_INITIAL (decl) == NULL_TREE should
be there, given that [class.static.data]/4 says that the definition should
be present even for const qualified static data members with initializers
in the class, but removing that line breaks a bunch of testcases in the
testsuite.

The problem is that decl_needed_p isn't a strong enough test; I think we set TREE_USED even if we just pull out the constant value of a static data member. We only need a definition for it if we try to use its address.


Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]