https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66976
Bug ID: 66976 Summary: Compiler error for well-formed program with a definition of a constexpr function returning void Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: anders.granlund.0 at gmail dot com Target Milestone: --- The following program (prog.cc in the command line below) is well-formed: constexpr void f() {} int main() {} Note that the return type void is a literal type according to [basic.types]/10: http://eel.is/c++draft/basic.types#10 I compiled the program with the following command line: gcc prog.cc -std=c++11 -pedantic-errors I expected to get no errors since the program is well-formed, but I got the following error: prog.cc: In function 'constexpr void f()': prog.cc:1:16: error: invalid return type 'void' of constexpr function 'constexpr void f()'constexpr void f() {} ^ For comparison Clang accepts the program without errors. Output for gcc -v (I think the bug quite independent of this however): Using built-in specs. COLLECT_GCC=/usr/local/gcc-head/bin/g++ COLLECT_LTO_WRAPPER=/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /home/heads/gcc/gcc-source/configure --prefix=/usr/local/gcc-head --enable-languages=c,c++ --enable-lto --disable-multilib --without-ppl --without-cloog-ppl --enable-checking=release --disable-nls Thread model: posix gcc version 6.0.0 20150722 (experimental) (GCC) COLLECT_GCC_OPTIONS='-o' 'prog.exe' '-std=c++11' '-pedantic-errors' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE prog.cc -quiet -dumpbase prog.cc -mtune=generic -march=x86-64 -auxbase prog -pedantic-errors -std=c++11 -version -o /tmp/ccE6wwKW.s GNU C++11 (GCC) version 6.0.0 20150722 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 6.0.0 20150722 (experimental), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1 warning: GMP header version 5.1.2 differs from library version 5.0.2. warning: MPFR header version 3.1.2 differs from library version 3.1.0-p3. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" ignoring nonexistent directory "/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../../include/c++/6.0.0 /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../../include/c++/6.0.0/x86_64-unknown-linux-gnu /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../../include/c++/6.0.0/backward /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/include /usr/local/include /usr/local/gcc-head/include /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/include-fixed /usr/include/x86_64-linux-gnu /usr/include End of search list. GNU C++11 (GCC) version 6.0.0 20150722 (experimental) (x86_64-unknown-linux-gnu) compiled by GNU C version 6.0.0 20150722 (experimental), GMP version 5.1.2, MPFR version 3.1.2, MPC version 1.0.1 warning: GMP header version 5.1.2 differs from library version 5.0.2. warning: MPFR header version 3.1.2 differs from library version 3.1.0-p3. GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 9115218d8690e08d2bbd8844106c0d12 COLLECT_GCC_OPTIONS='-o' 'prog.exe' '-std=c++11' '-pedantic-errors' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' as -v --64 -o /tmp/cc8TSYhs.o /tmp/ccE6wwKW.s GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.22 COMPILER_PATH=/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/:/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/:/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/:/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/:/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/ LIBRARY_PATH=/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/:/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../../lib64/:/lib/x86_64-linux-gnu/:/lib/../lib64/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib64/:/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../:/lib/:/usr/lib/ COLLECT_GCC_OPTIONS='-o' 'prog.exe' '-std=c++11' '-pedantic-errors' '-v' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/collect2 -plugin /usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/liblto_plugin.so -plugin-opt=/usr/local/gcc-head/libexec/gcc/x86_64-unknown-linux-gnu/6.0.0/lto-wrapper -plugin-opt=-fresolution=/tmp/cc4yk1QX.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o prog.exe /usr/lib/x86_64-linux-gnu/crt1.o /usr/lib/x86_64-linux-gnu/crti.o /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/crtbegin.o -L/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0 -L/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../../../lib64 -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib64 -L/usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/../../.. -rpath /usr/local/gcc-head/lib64 -lpthread /tmp/cc8TSYhs.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/local/gcc-head/lib/gcc/x86_64-unknown-linux-gnu/6.0.0/crtend.o /usr/lib/x86_64-linux-gnu/crtn.o