This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54903] New: Auto + static in-class constant initalization not working
- From: "rhalbersma at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Oct 2012 18:53:45 +0000
- Subject: [Bug c++/54903] New: Auto + static in-class constant initalization not working
- Auto-submitted: auto-generated
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: unassigned@gcc.gnu.org
ReportedBy: rhalbersma@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