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

            Bug ID: 58888
           Summary: [c++11] Rejects-valid: static member with auto and
                    initializer
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thomas.br...@virtuell-zuhause.de

The following code is rejected by 
~/gcc-4.8.2/bin/g++ -std=c++11 test.cpp
########
#include <iostream>

struct A
{
  static constexpr auto b{1.0};
};

constexpr decltype(A::b) A::b;

int main(int argc, char** argv)
{
  std::cout << &A::b << std::endl;
}
########

with the message

#########
test.cpp:46:30: error: invalid use of 'auto'
   static constexpr auto b{1.0};
                              ^
test.cpp:49:30: error: invalid type in declaration before ';' token
 constexpr decltype(A::b) A::b;
                              ^
test.cpp:49:30: error: declaration of 'constexpr<typeprefixerror> A::b' outside
of class is not definition [-fpermissive]
#########

I'm using g++ (GCC) 4.8.2.

My interpretation of &7.1.6.4 is that this code is valid, clang accepts the
code and
http://stackoverflow.com/questions/12834874/auto-static-in-class-constant-initalization-with-meta-programming
also suggests that it is valid.

Reply via email to