https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69700
Bug ID: 69700 Summary: [C++14] constexpr incorrectly implies const Product: gcc Version: 5.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: michael.price at synopsys dot com Target Milestone: --- Created attachment 37602 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=37602&action=edit preprocessed source The following code (derived from the subject of CWG DR 1683) should be ill-formed in C++14: struct A { constexpr A() {} constexpr operator int() { return 1; } }; template <int> struct X {}; constexpr A a; X<a> x; GCC compiles it as if it were C++11, under which it is well-formed. The output below is from 5.2.0, but the behavior 4.9.0 through 5.3.0 seemed consistent. $ g++ -v -save-temps -c -std=c++14 constexpr-vs-const.cpp Using built-in specs. COLLECT_GCC=/opt/pkg/gcc-5.2.0/bin/g++ Target: x86_64-unknown-linux-gnu Configured with: ../gcc-5.2.0/configure --prefix=/opt/pkg/gcc-5.2.0 --program-suffix=-5.2.0 --enable-languages=c,c++ Thread model: posix gcc version 5.2.0 (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++14' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/pkg/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE constexpr-vs-const.cpp -mtune=generic -march=x86-64 -std=c++14 -fpch-preprocess -o constexpr-vs-const.ii ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0 /opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/x86_64-unknown-linux-gnu /opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../include/c++/5.2.0/backward /opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/include /usr/local/include /opt/pkg/gcc-5.2.0/include /opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++14' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /opt/pkg/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/cc1plus -fpreprocessed constexpr-vs-const.ii -quiet -dumpbase constexpr-vs-const.cpp -mtune=generic -march=x86-64 -auxbase constexpr-vs-const -std=c++14 -version -o constexpr-vs-const.s GNU C++14 (GCC) version 5.2.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 5.2.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++14 (GCC) version 5.2.0 (x86_64-unknown-linux-gnu) compiled by GNU C version 5.2.0, GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: d48b14d3a677b3306bfa594605d7fb25 COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++14' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as -v --64 -o constexpr-vs-const.o constexpr-vs-const.s GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.22 COMPILER_PATH=/opt/pkg/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/:/opt/pkg/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/5.2.0/:/opt/pkg/gcc-5.2.0/libexec/gcc/x86_64-unknown-linux-gnu/:/opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/:/opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/ LIBRARY_PATH=/opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/:/opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/opt/pkg/gcc-5.2.0/lib/gcc/x86_64-unknown-linux-gnu/5.2.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-std=c++14' '-shared-libgcc' '-mtune=generic' '-march=x86-64' $