[Bug c++/29365] Unnecessary anonymous namespace warnings

pinskia at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Aug 28 22:11:00 GMT 2007



------- Comment #37 from pinskia at gmail dot com  2007-08-28 22:11 -------
Subject: Re:  Unnecessary anonymous namespace warnings

On 28 Aug 2007 21:41:05 -0000, bangerth at dealii dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
> That's what I thought too at first, but the request is valid anyway as long
> as you never use the pointer to the class from anywhere except the one
> implementation file in which the class is defined.

No it is not, it is still violating One definition rule as struct X
will have a different member type for pimpl_ in each TU (this violates
the whole idea of types being exported).  This is going to be true no
matter what, even if you change the warning.  Now you can use a
"void*" to get around this issue and should solve the issue and not
violate the C++ ODR.

This warning is not about style, it is about warning when you are most
likely going to violat C++'s One definition rule with anonymous
namespaces and you do violate it here as explained above.

Thanks,
Andrew Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29365



More information about the Gcc-bugs mailing list