[cfe-dev] clang vs GCC error case: both ‘const’ and ‘constexpr’ cannot be used here
Stephen Kelly
steveire at gmail.com
Mon Jul 23 01:34:44 PDT 2012
Hi there,
clang compiles the following code, but GCC does not:
#include <iostream>
static constexpr const char Data[] = {
'D', 'A', 'T', 'A',
};
static constexpr const char *data_func() { return Data; }
int main(int argc, char **argv)
{
char c = 'T';
switch(c)
{
case *data_func():
std::cout << "GOT A D" << std::endl;
break;
case *(data_func() + 2):
std::cout << "GOT A T" << std::endl;
}
}
$ clang++ --version
clang version 3.2
Target: x86_64-unknown-linux-gnu
Thread model: posix
$ g++ -dumpversion
4.6.1
$ g++ main.cpp -std=c++0x
main.cpp:163:48: error: both ‘const’ and ‘constexpr’ cannot be used here
Which compiler is buggy?
Thanks,
Steve.
More information about the cfe-dev
mailing list