public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/53972] New: array constant expression expression not valid as template argument
@ 2012-07-15 13:25 fw at gcc dot gnu.org
2021-08-05 6:49 ` [Bug c++/53972] array constant " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: fw at gcc dot gnu.org @ 2012-07-15 13:25 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53972
Bug #: 53972
Summary: array constant expression expression not valid as
template argument
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: fw@gcc.gnu.org
Instantiating sub1 failes with:
bug.cc:10:24: error: ‘array’ is not a constant expression
return Constify<array[I]>::value;
This is inconsistent because sub2 shows that the array subscript is recognized
as a constant expression in other context.
template <unsigned I>
struct Constify {
enum { value = I };
};
template <unsigned N>
constexpr char
sub1(const char (&array)[N], unsigned I)
{
return Constify<array[I]>::value;
}
template <unsigned N>
constexpr char
sub2(const char (&array)[N], unsigned I)
{
return array[I];
}
int
main()
{
sub1("foo", 2);
enum {
value = sub2("foo", 2)
};
Constify<value>::value;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/53972] array constant expression not valid as template argument
2012-07-15 13:25 [Bug c++/53972] New: array constant expression expression not valid as template argument fw at gcc dot gnu.org
@ 2021-08-05 6:49 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-05 6:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53972
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I cannot get any compiler to accept sub1("foo", 2);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-05 6:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-15 13:25 [Bug c++/53972] New: array constant expression expression not valid as template argument fw at gcc dot gnu.org
2021-08-05 6:49 ` [Bug c++/53972] array constant " pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).