Summary: | [6 Regression] constexpr leaves reference member var uninitialized | ||
---|---|---|---|
Product: | gcc | Reporter: | Stephan Bergmann <sberg.fun> |
Component: | c++ | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | daniel.kruegler, doko, jakub, jason, webrown.cpp |
Priority: | P1 | Keywords: | wrong-code |
Version: | 6.0 | ||
Target Milestone: | 6.0 | ||
Host: | Target: | ||
Build: | Known to work: | 5.3.1 | |
Known to fail: | 6.0 | Last reconfirmed: | 2016-01-22 00:00:00 |
Description
Stephan Bergmann
2016-01-17 09:34:54 UTC
$ cat tst.cc struct S { constexpr S(int & x): n(x) {} int & n; }; constexpr S f1(int & x) { return S(x); } constexpr S f2(int & x) { return f1(x); } S f3(int & x) { return f2(x); } int main() { int n = 1; return f3(n).n; } $ g++ -std=c++11 tst.cc && ./a.out Segmentation fault (core dumped) (In reply to Matthias Klose from comment #2) > r232725 That commit is newer than Stephan's original report. Started with r230365. In the testcase for testsuite you want f3(n).n == 1 instead, otherwise it will fail with non-zero return code even if not miscompiled. I think there is a dup of this bug somewhere too. |