This is the mail archive of the gcc-help@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]

Potentially bogus warning about anonymous types


Hello,

A while ago I encountered what I believed to be a bogus warning 
of the form "... uses the anonymous namespace" with GCC 4.8.

I posted http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54060 ,
and I was told there that:

 1. The warning is meant to say "... uses an anonymous type"
    rather than "... uses the anonymous namespace".
 2. Aside from the poor wording, the warning is not bogus
    because it points out a potential ODR violation.

I recently encountered the same warning in a different situation,
but I don't see where the potential ODR violation is this time.
I suspect there may not be one (and thus the warning really is
bogus in this case), but I wanted to double-check before filing
a bug.

Here is the code in question:


test.cpp:

#include "test.hpp"


test.hpp:

template <typename T>
struct base
{
    static const bool value = true;
};

template <bool>
struct outer;

template <>
struct outer<false>
{
    template <typename T> 
    struct inner : public base<T>
    {
    };
};

bool foo()
{
    auto lambda = [](){};
    typedef decltype(lambda) Lambda;
    return outer<false>::inner<Lambda>::value;
}



When compiling test.cpp, I get the following warning:

In file included from test.cpp:1:0:
test.hpp: In instantiation of 'struct outer<false>::inner<foo()::__lambda0>':
test.hpp:23:39:   required from here
test.hpp:14:12: warning: 'outer<false>::inner<foo()::__lambda0>' has a base 'base<foo()::__lambda0>' whose type uses the anonymous namespace [enabled by default]
     struct inner : public base<T>
            ^


Could someone please confirm whether there is an ODR violation
here, and if so explain what it is?

Thanks!

Nate 		 	   		  

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