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



             Bug #: 54903

           Summary: Auto + static in-class constant initalization not

                    working

    Classification: Unclassified

           Product: gcc

           Version: 4.7.2

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c++

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: rhalber...@gmail.com





template<int N, int D>

struct Modulus

{

        static auto const value = N % D;

};



template<int N>

struct Angle

{

        static auto const value = Modulus<N, 360>::value; // ERROR

        //static int const value = Modulus<N, 360>::value;  // OK

        //static auto const value = N % 360;                // OK



        typedef Angle<value> type;

};



I cannot do static auto const = Modulus<N, 360>::value, with either MinGW gcc

4.7.2 (Nuwen distro) or Ideone (gcc 4.5.1). Instead, I have to either

explicitly denote the type as static int const value = Modulus<N, 360>::value

or I have to use auto with the full modular expression as static auto const

value = N % 360;.



The code appears to be Standard compliant and works on both Visual C++ 2010

Express and Clang 3.1



Link to Stackoverflow: http://stackoverflow.com/q/12834874/819272

Reply via email to