Bug 92432 - Regression: ICE on non-constant expression as template argument
Summary: Regression: ICE on non-constant expression as template argument
Status: UNCONFIRMED
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
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-09 13:58 UTC by Daniel Kirchner
Modified: 2019-11-10 13:52 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

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; }