https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78743
Bug ID: 78743
Summary: g++ segfaults when printing warning for captured
constexpr variable
Product: gcc
Version: 6.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: bjarni.sigurdsson at marel dot com
Target Milestone: ---
The following code will result in a segmentation fault when compiled with g++
version 6.2.0.
// --
static constexpr double foo = 1.0;
int main()
{
auto foobar = [foo](){return (double)foo;};
return 0;
}
// --
Example compile output from "g++ test_crash.cpp":
test_crash.cpp: In function 'int main()':
test_crash.cpp:5:20: warning: capture of variable 'foo' with non-automatic
storage duration
auto foobar = [foo](){return (double)foo;};
^~~
'
Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Fixing the warning of course resolves the crash, but also removing the
constexpr:
// --
static double foo = 1.0;
int main()
{
auto foobar = [foo](){return (double)foo;};
return 0;
}
// --
Example output from "g++ test_ok.cpp":
test_ok.cpp: In function 'int main()':
test_ok.cpp:5:20: warning: capture of variable 'foo' with non-automatic storage
duration
auto foobar = [foo](){return (double)foo;};
^~~
test_ok.cpp:1:15: note: 'double foo' declared here
static double foo = 1.0;
^~~
GCC 6.2.0 was built with the following options:
Configured with: ../gcc-6.2.0/configure --prefix=/opt/plutotoolchain
--target=i686-marel-linux-gnu --with-sysroot=/opt/pluto-targets/i386-rootfs/
--enable-languages=c,c++ --enable-threads=posix --enable-shared
--disable-multilib --enable-__cxa_atexit --disable-sjlj-exceptions
--disable-nls --disable-decimal-float --disable-fixed-point
--enable-checking=release --enable-symvers=gnu --enable-c99 --enable-long-long
--enable-profile --with-system-zlib
--with-default-libstdcxx-abi=gcc4-compatible --with-tune=intel