public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-29 20:07 ` pinskia at gcc dot gnu.org
2013-03-28 6:58 ` mpolacek at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-11-29 20:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |przemoc at gmail dot com
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-11-29 19:37:32 UTC ---
*** Bug 46711 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
2010-11-29 20:07 ` [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing pinskia at gcc dot gnu.org
@ 2013-03-28 6:58 ` mpolacek at gcc dot gnu.org
2013-03-28 8:54 ` jakub at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2013-03-28 6:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> 2013-03-28 06:57:56 UTC ---
*** Bug 56759 has been marked as a duplicate of this bug. ***
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
2010-11-29 20:07 ` [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing pinskia at gcc dot gnu.org
2013-03-28 6:58 ` mpolacek at gcc dot gnu.org
@ 2013-03-28 8:54 ` jakub at gcc dot gnu.org
2013-04-03 10:00 ` jakub at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-03-28 8:54 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-03-28 08:53:54 UTC ---
Created attachment 29742
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=29742
gcc49-pr19449.patch
Untested patch. There is another case where we'd better fold
__builtin_constant_p right away, for static/extern function-local array
dimensions:
int y;
static char a[__builtin_constant_p (y) ? -1 : 1];
extern char b[__builtin_constant_p (y) ? -1 : 1];
char d[__builtin_constant_p (y) ? -1 : 1];
void
foo (int x)
{
static char e[__builtin_constant_p (x) ? -1 : 1];
extern char f[__builtin_constant_p (x) ? -1 : 1];
auto char g[__builtin_constant_p (x) ? -1 : 1];
char h[__builtin_constant_p (x) ? -1 : 1];
}
Right now this compiles fine for -O0, but for -O1 and above it errors on e and
f (twice on the latter actually). When cfun == NULL, we always fold
__builtin_constant_p right away, but when cfun is NULL, we don't consider
static/extern. Not sure how to fix this issue though, because I think the
declspecs aren't passed down to declarator parsing.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2013-03-28 8:54 ` jakub at gcc dot gnu.org
@ 2013-04-03 10:00 ` jakub at gcc dot gnu.org
2013-11-27 20:57 ` desrt at desrt dot ca
2021-02-10 23:39 ` msebor at gcc dot gnu.org
5 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-04-03 10:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2013-04-03 10:00:19 UTC ---
Author: jakub
Date: Wed Apr 3 09:17:44 2013
New Revision: 197393
URL: http://gcc.gnu.org/viewcvs?rev=197393&root=gcc&view=rev
Log:
PR c/19449
* tree.h (force_folding_builtin_constant_p): New decl.
* builtins.c (force_folding_builtin_constant_p): New variable.
(fold_builtin_constant_p): Fold immediately also if
force_folding_builtin_constant_p.
* c-parser.c (c_parser_get_builtin_args): Add choose_expr_p
argument. If set, or it temporarily for parsing of the first
argument into force_folding_builtin_constant_p.
(c_parser_postfix_expression): Adjust callers.
* gcc.c-torture/execute/pr19449.c: New test.
Added:
trunk/gcc/testsuite/gcc.c-torture/execute/pr19449.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/builtins.c
trunk/gcc/c/ChangeLog
trunk/gcc/c/c-parser.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/tree.h
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2013-04-03 10:00 ` jakub at gcc dot gnu.org
@ 2013-11-27 20:57 ` desrt at desrt dot ca
2021-02-10 23:39 ` msebor at gcc dot gnu.org
5 siblings, 0 replies; 9+ messages in thread
From: desrt at desrt dot ca @ 2013-11-27 20:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
Ryan Lortie <desrt at desrt dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |desrt at desrt dot ca
--- Comment #7 from Ryan Lortie <desrt at desrt dot ca> ---
Another case, and this one fails at all optimisation levels:
int a(void) { return 0; }
/* This always returns a constant expression. If we can't statically
* determine its value, then this is the constant expression '0'.
*/
#define CONSTIFY(x) (__builtin_constant_p(x)&&(x))
/* works fine */
int b = CONSTIFY(a());
int c = CONSTIFY(a()) ? 2 : 3;
/* fails */
int d = __builtin_choose_expr(CONSTIFY(a()), 2, 3);
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2013-11-27 20:57 ` desrt at desrt dot ca
@ 2021-02-10 23:39 ` msebor at gcc dot gnu.org
5 siblings, 0 replies; 9+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-02-10 23:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2005-12-18 01:38:34 |2021-2-10
Known to fail| |11.0, 3.4.2
CC| |msebor at gcc dot gnu.org
--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
No change in GCC 11:
$ gcc -O -S -Wall pr19449.c
pr19449.c: In function ‘foo’:
pr19449.c:9:15: error: storage size of ‘e’ isn’t constant
9 | static char e[__builtin_constant_p (x) ? -1 : 1];
| ^
pr19449.c:10:15: error: object with variably modified type must have no linkage
10 | extern char f[__builtin_constant_p (x) ? -1 : 1];
| ^
pr19449.c:10:15: error: storage size of ‘f’ isn’t constant
pr19449.c:12:8: warning: unused variable ‘h’ [-Wunused-variable]
12 | char h[__builtin_constant_p (x) ? -1 : 1];
| ^
pr19449.c:11:13: warning: unused variable ‘g’ [-Wunused-variable]
11 | auto char g[__builtin_constant_p (x) ? -1 : 1];
| ^
pr19449.c:10:15: warning: unused variable ‘f’ [-Wunused-variable]
10 | extern char f[__builtin_constant_p (x) ? -1 : 1];
| ^
pr19449.c:9:15: warning: unused variable ‘e’ [-Wunused-variable]
9 | static char e[__builtin_constant_p (x) ? -1 : 1];
| ^
At top level:
pr19449.c:2:13: warning: ‘a’ defined but not used [-Wunused-variable]
2 | static char a[__builtin_constant_p (y) ? -1 : 1];
| ^
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
2005-01-14 19:11 [Bug c/19449] New: " eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
2005-01-14 19:22 ` eplondke at gmail dot com
@ 2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-01-14 19:26 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-01-14 19:26 -------
The problem is the __builtin_constant_p is delayed for evalutation until optimizations are run but
__builtin_choose_expr needs an answer right away.
What we could do is for when processing the first argument of __builtin_choose_expr, say we are not in
a function.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
GCC build triplet|i686-pc-cygwin |
GCC host triplet|i686-pc-cygwin |
GCC target triplet|arm-unknown-elf |
Keywords| |rejects-valid
Last reconfirmed|0000-00-00 00:00:00 |2005-01-14 19:26:10
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
2005-01-14 19:11 [Bug c/19449] New: " eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
@ 2005-01-14 19:22 ` eplondke at gmail dot com
2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 9+ messages in thread
From: eplondke at gmail dot com @ 2005-01-14 19:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From eplondke at gmail dot com 2005-01-14 19:22 -------
Created an attachment (id=7961)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=7961&action=view)
Test case as a file.
Test case as a file.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 9+ messages in thread
* [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing
2005-01-14 19:11 [Bug c/19449] New: " eplondke at gmail dot com
@ 2005-01-14 19:14 ` ian at airs dot com
2005-01-14 19:22 ` eplondke at gmail dot com
2005-01-14 19:26 ` pinskia at gcc dot gnu dot org
2 siblings, 0 replies; 9+ messages in thread
From: ian at airs dot com @ 2005-01-14 19:14 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |ian at airs dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-02-10 23:39 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-19449-4@http.gcc.gnu.org/bugzilla/>
2010-11-29 20:07 ` [Bug c/19449] __builtin_constant_p cannot resolve to const when optimizing pinskia at gcc dot gnu.org
2013-03-28 6:58 ` mpolacek at gcc dot gnu.org
2013-03-28 8:54 ` jakub at gcc dot gnu.org
2013-04-03 10:00 ` jakub at gcc dot gnu.org
2013-11-27 20:57 ` desrt at desrt dot ca
2021-02-10 23:39 ` msebor at gcc dot gnu.org
2005-01-14 19:11 [Bug c/19449] New: " eplondke at gmail dot com
2005-01-14 19:14 ` [Bug c/19449] " ian at airs dot com
2005-01-14 19:22 ` eplondke at gmail dot com
2005-01-14 19:26 ` pinskia 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).