This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/54086] New: GCC should allow constexpr and const together
- From: "steveire at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 24 Jul 2012 15:47:35 +0000
- Subject: [Bug c++/54086] New: GCC should allow constexpr and const together
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54086
Bug #: 54086
Summary: GCC should allow constexpr and const together
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: steveire@gmail.com
GCC and Clang differ in how they handle this code. Clang compiles it, 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
http://thread.gmane.org/gmane.comp.compilers.clang.devel/22984
Thanks,