https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86491

--- Comment #6 from Jason Vas Dias <jason.vas.dias at gmail dot com> ---
Thanks Andrew!

But, please explain, why does using a static reference cause
anonymous namespace issues ?
Where is this mandated in the C++ standards ?

I understand that any reference to a static object can violate the ODR
rule IFF multiple translation units that contain references to the "same"
static object are combined. But how does that involve anonymous namespace
issues?

Maybe GCC should provide some mechanism to detect static references,
report them separately as a new  "-Wstatic-reference"? warning ,
and NOT bring in 'anonymous namespace' usage issues at all ?
It is purely a semantic difference - I agree SOME warning should
have been issued - but complaining about 'anonymous namespace'
when it means 'static reference' is really confusing.
There are NO objects named '{anon::}' in the program.
Couldn't GCC have some trigger on the creation of an '{anon}::'
reference, and use it to report the anonymous namespace usage,
and if none existed, complain about the static reference usage ?

Thanks & Best Regards,
Jason


On 11/07/2018, pinskia at gcc dot gnu.org <gcc-bugzi...@gcc.gnu.org> wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86491
>
> Andrew Pinski <pinskia at gcc dot gnu.org> changed:
>
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>            Keywords|                            |diagnostic
>
> --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
> It is not complaining about d in main but rather N::D.  The warning is done
> before it reaches main.
>
> Really the warning should be clearer as you are not using an anonymous
> namespace rather static linkage which is also causes an anonymous namespace
> issues.

Reply via email to