public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52567] New: constant expression not recognized as being constant
@ 2012-03-12 17:48 l_belev at yahoo dot com
2012-03-12 18:10 ` [Bug c++/52567] " marc.glisse at normalesup dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: l_belev at yahoo dot com @ 2012-03-12 17:48 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52567
Bug #: 52567
Summary: constant expression not recognized as being constant
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: l_belev@yahoo.com
when trying to compile the following simple c++ code fragment, gcc gives error
"error: field initializer is not constant"
class RSpans {
public:
static const int max_span = (1<<31)-1;
};
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52567] constant expression not recognized as being constant
2012-03-12 17:48 [Bug c++/52567] New: constant expression not recognized as being constant l_belev at yahoo dot com
@ 2012-03-12 18:10 ` marc.glisse at normalesup dot org
2012-03-12 18:29 ` paolo.carlini at oracle dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marc.glisse at normalesup dot org @ 2012-03-12 18:10 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52567
--- Comment #1 from Marc Glisse <marc.glisse at normalesup dot org> 2012-03-12 18:10:16 UTC ---
1<<31 overflows and is thus not a constant. Try maybe 1LL<<31 ?
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52567] constant expression not recognized as being constant
2012-03-12 17:48 [Bug c++/52567] New: constant expression not recognized as being constant l_belev at yahoo dot com
2012-03-12 18:10 ` [Bug c++/52567] " marc.glisse at normalesup dot org
@ 2012-03-12 18:29 ` paolo.carlini at oracle dot com
2012-03-12 20:56 ` l_belev at yahoo dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-03-12 18:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52567
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-03-12 18:28:55 UTC ---
Or even 1U, afaics.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52567] constant expression not recognized as being constant
2012-03-12 17:48 [Bug c++/52567] New: constant expression not recognized as being constant l_belev at yahoo dot com
2012-03-12 18:10 ` [Bug c++/52567] " marc.glisse at normalesup dot org
2012-03-12 18:29 ` paolo.carlini at oracle dot com
@ 2012-03-12 20:56 ` l_belev at yahoo dot com
2012-03-12 21:00 ` pinskia at gcc dot gnu.org
2012-03-12 21:08 ` l_belev at yahoo dot com
4 siblings, 0 replies; 6+ messages in thread
From: l_belev at yahoo dot com @ 2012-03-12 20:56 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52567
--- Comment #3 from Luchezar Belev <l_belev at yahoo dot com> 2012-03-12 20:56:10 UTC ---
It overflows alright, but what this has to do with not being constant?
An overflow in a constant expression makes it variable? I fail to see the logic
here
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52567] constant expression not recognized as being constant
2012-03-12 17:48 [Bug c++/52567] New: constant expression not recognized as being constant l_belev at yahoo dot com
` (2 preceding siblings ...)
2012-03-12 20:56 ` l_belev at yahoo dot com
@ 2012-03-12 21:00 ` pinskia at gcc dot gnu.org
2012-03-12 21:08 ` l_belev at yahoo dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-03-12 21:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52567
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-03-12 20:59:39 UTC ---
An overflow in an integer expression is never an integer constant expression.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/52567] constant expression not recognized as being constant
2012-03-12 17:48 [Bug c++/52567] New: constant expression not recognized as being constant l_belev at yahoo dot com
` (3 preceding siblings ...)
2012-03-12 21:00 ` pinskia at gcc dot gnu.org
@ 2012-03-12 21:08 ` l_belev at yahoo dot com
4 siblings, 0 replies; 6+ messages in thread
From: l_belev at yahoo dot com @ 2012-03-12 21:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52567
--- Comment #5 from Luchezar Belev <l_belev at yahoo dot com> 2012-03-12 21:08:07 UTC ---
Ok, but at least the error message should be changed to tell about overflow.
For example the following code gives error too, but it says
"error: overflow in constant expression"
which is more clear
int foo(int x) {
switch (x) {
case 1: return 5;
case (1<<31)-1: return 7;
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-03-12 21:08 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12 17:48 [Bug c++/52567] New: constant expression not recognized as being constant l_belev at yahoo dot com
2012-03-12 18:10 ` [Bug c++/52567] " marc.glisse at normalesup dot org
2012-03-12 18:29 ` paolo.carlini at oracle dot com
2012-03-12 20:56 ` l_belev at yahoo dot com
2012-03-12 21:00 ` pinskia at gcc dot gnu.org
2012-03-12 21:08 ` l_belev at yahoo dot com
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).