public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions
@ 2005-01-25 20:33 austern at apple dot com
2005-01-25 20:44 ` [Bug c++/19628] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: austern at apple dot com @ 2005-01-25 20:33 UTC (permalink / raw)
To: gcc-bugs
The following test case is accepted by 3.3 (both C and C++) and by 4.0 C, but not by 4.0 C++.
#define FOO(x) (__builtin_constant_p(x) ? 1 : 2)
int foo(int n) {
switch(n) {
case FOO(3):
return 1;
default:
return 2;
}
}
Was this change intentional? Even if it was, the C/C++ incompatibility is unfortunate. This sort of
construct is likely to appear in headers used by both languages. (And we can't very well point to
language standards in deciding whether __builtin_constant_p should be considered a constant-
expression, since it's a GNU extension.)
--
Summary: g++ no longer accepts __builtin_constant_p in constant-
expressions
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: austern at apple dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.7.0
GCC host triplet: powerpc-apple-darwin7.7.0
GCC target triplet: powerpc-apple-darwin7.7.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
@ 2005-01-25 20:44 ` pinskia at gcc dot gnu dot org
2005-01-28 20:17 ` austern at apple dot com
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-25 20:44 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-25 20:44 -------
: Search converges between 2003-01-27-trunk (#173) and 2003-02-03-trunk (#174).
I should note this was not accepted before:
: Search converges between 2001-01-14-trunk (#2) and 2001-01-21-trunk (#3).
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Summary|g++ no longer accepts |[3.4/4.0 Regression] g++ no
|__builtin_constant_p in |longer accepts
|constant-expressions |__builtin_constant_p in
| |constant-expressions
Target Milestone|--- |3.4.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
2005-01-25 20:44 ` [Bug c++/19628] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
@ 2005-01-28 20:17 ` austern at apple dot com
2005-01-29 17:32 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: austern at apple dot com @ 2005-01-28 20:17 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From austern at apple dot com 2005-01-28 20:17 -------
This was undoubtedly caused by Mark's large checkin on 2003-01-29, which included changes to
constant-expression handling.
I do not believe the __builtin_constant_p change was deliberate. The intent behind this patch, as far as
I can tell, was to reject constructs that the C++ standard explicitly says are not constant-expressions,
such as "(1, 2)". It looks to me like rejecting GNU extensions like __builtin_constant_p in constant-
expressions was just a side effect.
As far as I can tell, rejecting __builtin_constant_p is a change that (a) was not deliberate; (b) is
undocumented; (c) introduced a C/C++ incompatbility; and (d) causes previously working code to
break. I think that justifies calling it a bug.
--
What |Removed |Added
----------------------------------------------------------------------------
Keywords|rejects-valid |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
2005-01-25 20:44 ` [Bug c++/19628] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-28 20:17 ` austern at apple dot com
@ 2005-01-29 17:32 ` pinskia at gcc dot gnu dot org
2005-01-30 19:56 ` pinskia at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-29 17:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-29 17:31 -------
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg02167.html>.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |patch, rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2005-01-29 17:31:57
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
` (2 preceding siblings ...)
2005-01-29 17:32 ` pinskia at gcc dot gnu dot org
@ 2005-01-30 19:56 ` pinskia at gcc dot gnu dot org
2005-01-31 1:39 ` mmitchel at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-30 19:56 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-30 19:56 -------
New patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg02212.html>.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
` (3 preceding siblings ...)
2005-01-30 19:56 ` pinskia at gcc dot gnu dot org
@ 2005-01-31 1:39 ` mmitchel at gcc dot gnu dot org
2005-01-31 2:38 ` austern at apple dot com
2005-05-19 17:24 ` [Bug c++/19628] [3.4 " mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-01-31 1:39 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From mmitchel at gcc dot gnu dot org 2005-01-31 01:39 -------
I agree that __builtin_constant_p should be allowed in an integral
constant-expression.
The only thing I don't like about the patch is that the documentation for
builtin_is_constant_p doesn't obviously match the name; the documentation says
it checks for built-ins that can appear in consant-expressions, but the name
might seem to refer exclusively to __builtin_constant_p. A name like
"builtin_valid_in_constant_expr_p" would seem better.
The patch is OK with that change.
(Matt, I think you should also check what happens when __builtin_constant_p is
used as a template argument with dependent arguments, like:
template <int I>
void f(int &[__builtin_constant_p (I) + 2]);
Do we issue errors at substitution time? If not, do we emit reasonable
manglings? Etc. We don't have to fix these issues before re-enabling the core
functionality, but if there are problems we should open new PRs for them.)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
` (4 preceding siblings ...)
2005-01-31 1:39 ` mmitchel at gcc dot gnu dot org
@ 2005-01-31 2:38 ` austern at apple dot com
2005-05-19 17:24 ` [Bug c++/19628] [3.4 " mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: austern at apple dot com @ 2005-01-31 2:38 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From austern at apple dot com 2005-01-31 02:38 -------
Subject: Re: [3.4/4.0 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
> it checks for built-ins that can appear in consant-expressions, but
> the name
> might seem to refer exclusively to __builtin_constant_p. A name like
> "builtin_valid_in_constant_expr_p" would seem better.
I agree, that's a better name. I'll change it.
> (Matt, I think you should also check what happens when
> __builtin_constant_p is
> used as a template argument with dependent arguments, like:
> template <int I>
> void f(int &[__builtin_constant_p (I) + 2]);
Actually, it ICEs. That would be a regression. I think I'd better fix
it before checking this in.
--Matt
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/19628] [3.4 Regression] g++ no longer accepts __builtin_constant_p in constant-expressions
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
` (5 preceding siblings ...)
2005-01-31 2:38 ` austern at apple dot com
@ 2005-05-19 17:24 ` mmitchel at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2005-05-19 17:24 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4.4 |3.4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19628
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2005-05-19 17:24 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-01-25 20:33 [Bug c++/19628] New: g++ no longer accepts __builtin_constant_p in constant-expressions austern at apple dot com
2005-01-25 20:44 ` [Bug c++/19628] [3.4/4.0 Regression] " pinskia at gcc dot gnu dot org
2005-01-28 20:17 ` austern at apple dot com
2005-01-29 17:32 ` pinskia at gcc dot gnu dot org
2005-01-30 19:56 ` pinskia at gcc dot gnu dot org
2005-01-31 1:39 ` mmitchel at gcc dot gnu dot org
2005-01-31 2:38 ` austern at apple dot com
2005-05-19 17:24 ` [Bug c++/19628] [3.4 " mmitchel at gcc dot gnu dot 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).