public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97401] New: static int has a default value?
@ 2020-10-13 11:17 tangyixuan at mail dot dlut.edu.cn
2020-10-13 11:38 ` [Bug c++/97401] " redi at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: tangyixuan at mail dot dlut.edu.cn @ 2020-10-13 11:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97401
Bug ID: 97401
Summary: static int has a default value?
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tangyixuan at mail dot dlut.edu.cn
Target Milestone: ---
Hi, the following code declares a static Integer without specific value.
Usually, it will has a default value '0', and thus 'b[a]' could be declared as
b[0] perhaps. However, gcc rejects it while clang accepts.
$ cat s.cpp
template<typename> struct A {
static int a;
char b[a];
};
$ g++ -c s.cpp
s.cpp:3:10: error: size of array ‘b’ is not an integral constant-expression
3 | char b[a];
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/97401] static int has a default value?
2020-10-13 11:17 [Bug c++/97401] New: static int has a default value? tangyixuan at mail dot dlut.edu.cn
@ 2020-10-13 11:38 ` redi at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2020-10-13 11:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97401
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to tangyixuan from comment #0)
> Usually, it will has a default value '0', and thus 'b[a]' could be declared
> as b[0] perhaps.
But b[0] would be ill-formed.
All compilers reject this if you actually instantiate the template, because
it's ill-formed.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-10-13 11:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 11:17 [Bug c++/97401] New: static int has a default value? tangyixuan at mail dot dlut.edu.cn
2020-10-13 11:38 ` [Bug c++/97401] " redi 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).