Bug 81862 - [C++11][constexpr] Constructor Parenthesized Initialization of Member Array Crash
Summary: [C++11][constexpr] Constructor Parenthesized Initialization of Member Array C...
Status: RESOLVED DUPLICATE of bug 86917
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.0.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on: 86917
Blocks: constexpr
  Show dependency treegraph
 
Reported: 2017-08-16 13:31 UTC by David Sanders
Modified: 2020-02-04 16:45 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-10-25 00:00:00


Attachments
Reproduce case (437 bytes, text/x-csrc)
2017-08-16 13:31 UTC, David Sanders
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Sanders 2017-08-16 13:31:12 UTC
Created attachment 41988 [details]
Reproduce case

Crash when using a parenthesized initialization of a member array with a constexpr constructor.

Whittled the reproduce case down as much as I could, all parts of the reproduce case source seem relevant to causing the crash. Switching to the standard initialization of the member array without parentheses fixes the crash.

Crash error:

main.cpp:46:46: internal compiler error: in verify_ctor_sanity, at cp/constexpr.c:2635
     constexpr Foo<int, bool> foobar(32, false);
Comment 1 Marek Polacek 2019-05-15 21:32:12 UTC
Started with r230365.  Most likely a dup of PR86917.
Comment 2 Marek Polacek 2019-05-15 21:33:20 UTC
Reduced.  But the PR86917 is much simpler, so I'd start with fixing that one.

template <unsigned long...> struct b;
template <typename, typename> struct g;
template <unsigned long... c, unsigned long... d> struct g<b<c...>, b<d...>> {
  using e = b<c..., d...>;
};
template <int f>
struct i : g<typename i<f / 2>::e, typename i<f - f / 2>::e> {};
template <> struct i<1> { typedef b<0> e; };
template <typename h, h...> struct j {};
template <typename h, h f, typename = typename i<f>::e> struct o;
template <typename h, h f, unsigned long... k> struct o<h, f, b<k...>> {
  typedef j<h, k...> e;
};
template <typename h, h f> using l = typename o<h, f>::e;
template <long... k> using m = j<unsigned long, k...>;
template <long f> using n = l<unsigned long, f>;
struct q {
  constexpr q(int) { }
};
template <int p> struct G { typedef q r[p]; };
template <int p> struct H {
  typename G<p>::r s;
  q operator[](long);
};
template <typename... t> class I {
public:
  constexpr I(t... v) : I(v..., n<5>{}) {}
  template <unsigned long... w>
  constexpr I(t... v, m<w...> x) : u({y(v..., x)[w]...}) {}
  template <unsigned long... w> auto y(t..., m<w...>) {
    H<5> a{w...};
    return a;
  }
  q u[5];
};
int main() { I<int, bool> c(2, false); }
Comment 3 Jason Merrill 2020-02-04 16:45:29 UTC
Yes, duplicate.

*** This bug has been marked as a duplicate of bug 86917 ***