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

--- Comment #3 from Roger Orr <rogero at howzatt dot demon.co.uk> ---
The following code block also gives an ODR violation with the same versions of
gcc; in this case only a *single* translation unit is involved.

$ cat test.cxx
#include <memory>

template<typename T>
class D : public T {
    using mfn_t = void (D::*)();
    std::tuple<mfn_t> data{&D::foo};
public:
    void foo() {
        std::get<0>(data);
    }
};

namespace {
    struct S {};
}

int main() {
    D<S> obj;
}

$ /opt/gcc-5.2.0/bin/g++ -flto -Wodr -std=c++11 test.cxx
test.cxx:5:32: warning: type 'struct mfn_t' violates one definition rule
[-Wodr]
     using mfn_t = void (D::*)();
                                ^
/opt/gcc-5.2.0/include/c++/5.2.0/tuple:764:21: note: a different type is
defined in another translation unit
       typedef _Head type;
                     ^
test.cxx:5:32: note: the first difference of corresponding definitions is field
'__pfn'
     using mfn_t = void (D::*)();
                                ^
test.cxx:5:32: note: a field of same name but different type is defined in
another translation unit
lto1: note: type mismatch in parameter 1
test.cxx:4:20: note: type 'struct D' defined in anonymous namespace can not
match type 'struct D'
 class D : public T {
                    ^
test.cxx:4:7: note: the incompatible type defined in anonymous namespace in
another translation unit
 class D : public T {
       ^

(Giving the anonymous namespace a name removes the warnings.)

Reply via email to