This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/54086] New: GCC should allow constexpr and const together


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,


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]