Bug 92432 - Regression: ICE on non-constant expression as template argument
Summary: Regression: ICE on non-constant expression as template argument
Status: RESOLVED DUPLICATE of bug 87765
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
Depends on:
Reported: 2019-11-09 13:58 UTC by Daniel Kirchner
Modified: 2020-01-29 20:37 UTC (History)
1 user (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed:


Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Kirchner 2019-11-09 13:58:40 UTC
Found on an up-to-date x86_64 archlinux system using "gcc 9.2.0-4".

However, I think this affects all versions of gcc >= 8.0 and is independent of the archlinux package.

Source code:

#include <array>
template<typename T> static constexpr void t(std::initializer_list<int> x) { std::array<int, x.size()> v; }

Results in:

t.cpp: In function 'constexpr void t(std::initializer_list<int>)':
t.cpp:2:102: internal compiler error: in coerce_template_parms, at cp/pt.c:8625

Expected (this should be what gcc < 8.0 does):

t.cpp: In function 'constexpr void t(std::initializer_list<int>)':
t.cpp:2:100:   in constexpr expansion of 'x.std::initializer_list<int>::size()'
t.cpp:2:102: error: 'x' is not a constant expression

I hope this is not a duplicate, but a search for "cp/pt.c:8625" yielded no results, so I guess this is new.
Comment 1 Andrew Pinski 2019-11-09 14:06:41 UTC
Maybe related to PR 86219.
Comment 2 Daniel Kirchner 2019-11-09 14:07:21 UTC
Might be a duplicate of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87765
Comment 3 Daniel Kirchner 2019-11-09 14:19:06 UTC
Non-STL test case:

struct X { int s(); };
template<int> using Y = void;
template<int> static constexpr void t(X x) { Y<x.s()> v; }
Comment 4 Marek Polacek 2020-01-29 20:37:49 UTC
Yes, it is a dup, but thanks for the nice testcase!

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