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

            Bug ID: 60167
           Summary: [4.9 regression] Bogus error: conflicting declaration
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ppluzhnikov at google dot com

The test case below fails to compile with current trunk:
g++ (GCC) 4.9.0 20140213 (experimental)

g++ -c t.cc
t.cc:10:48: error: conflicting declaration ‘typename Foo<F>::Bar Foo<F>::cache’
 template <int& F> typename Foo<F>::Bar Foo<F>::cache;
                                                ^
t.cc:5:14: note: previous declaration as ‘Foo<F>::Bar Foo<F>::cache’
   static Bar cache;
              ^
t.cc:10:48: error: declaration of ‘Foo<F>::Bar Foo<F>::cache’ outside of class
is not definition [-fpermissive]
 template <int& F> typename Foo<F>::Bar Foo<F>::cache;
                                                ^

/// --- cut ---
template <int& F>
struct Foo {
  typedef int Bar;

  static Bar cache;
};

// template <int& F> int Foo<F>::cache;  // OK

template <int& F> typename Foo<F>::Bar Foo<F>::cache;

/// --- cut ---

Removing reference (template <int F> struct Foo) also makes it compile.

Compiles fine with gcc-4.8 and Clang.

Reply via email to