[Bug c++/77482] New: Segfault when compiling ill-formed constexpr code
petschy at gmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Sep 5 10:22:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77482
Bug ID: 77482
Summary: Segfault when compiling ill-formed constexpr code
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: petschy at gmail dot com
Target Milestone: ---
Created attachment 39561
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=39561&action=edit
C++ source
In fixbuf(), the return statement is commented out at line 76. This makes the
program ill-formed since the return type will be deduced to void, but the
caller expects a value returned. Instead of an error message, 7.0 segfaults and
6.2.1 gets confused.
g++-7.0.0 -O3 -Wall -Wextra -g 20160905-constexpr-segfault.cpp
‘
In function ‘auto foo()’:
Segmentation fault
constexpr auto x = fixbuf<13, 200>();
----
6.2.1 doesn't segfault, but something is definitely amiss:
g++-6.2.1 -O3 -Wall -Wextra -g 20160905-constexpr-segfault.cpp
‘
20160905-constexpr-segfault.cpp:81: confused by earlier errors, bailing out
In a terminal window with black bg and gray font, the single quote is gray,
then the error message on the next line is bold white, and it stays so, so
anything I type after this will be bold white.
----
6.0 seems to be OK:
g++-6.0.0 -O3 -Wall -Wextra -g 20160905-constexpr-segfault.cpp
20160905-constexpr-segfault.cpp: In function ‘auto foo()’:
20160905-constexpr-segfault.cpp:81:37: error: ‘constexpr const void x’ has
incomplete type
constexpr auto x = fixbuf<13, 200>();
^
20160905-constexpr-segfault.cpp:82:9: error: unable to deduce ‘auto’ from ‘x’
return x;
^
20160905-constexpr-segfault.cpp: In function ‘auto foo_sized()’:
20160905-constexpr-segfault.cpp:87:38: error: ‘constexpr const void s’ has
incomplete type
constexpr auto s = fixbuf<13, 0, 1>();
^
20160905-constexpr-segfault.cpp:88:35: error: no matching function for call to
‘fixbuf()’
constexpr auto x = fixbuf<13, s>();
^
20160905-constexpr-segfault.cpp:69:6: note: candidate: template<unsigned int N,
unsigned int S, bool BOS> constexpr auto fixbuf()
auto fixbuf()
^~~~~~
20160905-constexpr-segfault.cpp:69:6: note: template argument
deduction/substitution failed:
20160905-constexpr-segfault.cpp:88:35: error: could not convert template
argument ‘s’ to ‘unsigned int’
constexpr auto x = fixbuf<13, s>();
^
20160905-constexpr-segfault.cpp:89:9: error: unable to deduce ‘auto’ from ‘x’
return x;
^
Tested on Debian Jessie AMD64, the detailed gcc versions:
$ g++-7.0.0 -v
Using built-in specs.
COLLECT_GCC=g++-7.0.0
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/7.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --disable-multilib
--program-suffix=-7.0.0 --disable-bootstrap CFLAGS='-O2 -march=native'
CXXFLAGS='-O2 -march=native'
Thread model: posix
gcc version 7.0.0 20160831 (experimental) (GCC)
$ g++-6.2.1 -v
Using built-in specs.
COLLECT_GCC=g++-6.2.1
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.2.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --disable-multilib
--program-suffix=-6.2.1 --disable-bootstrap CFLAGS='-O2 -march=native'
CXXFLAGS='-O2 -march=native'
Thread model: posix
gcc version 6.2.1 20160831 (GCC)
$ g++-6.0.0 -v
Using built-in specs.
COLLECT_GCC=g++-6.0.0
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --enable-languages=c,c++ --disable-multilib
--program-suffix=-6.0.0
Thread model: posix
gcc version 6.0.0 20160302 (experimental) (GCC)
More information about the Gcc-bugs
mailing list