public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/58275] New: __builtin_constant_p( expr ) returns true if expr is eliminated by CSE
@ 2013-08-29 19:40 tijl at coosemans dot org
  2013-08-29 19:46 ` [Bug c/58275] " glisse at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: tijl at coosemans dot org @ 2013-08-29 19:40 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58275

            Bug ID: 58275
           Summary: __builtin_constant_p( expr ) returns true if expr is
                    eliminated by CSE
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tijl at coosemans dot org

It appears that whenever the expression in __builtin_constant_p( expression )
can be eliminated __builtin_constant_p returns true even if expression is not a
compile-time constant.

Here is an example program. When compiled with -O it returns 1 instead of 2:

int main( int argc, char **argv ) {
    return( argc == 23 ? 0 : __builtin_constant_p( argc != 23 ) ? 1 : 2 );
}

% gcc49 -o test test.c -O
% ./test ; echo $?
1

If you change the first 23 into 24 the program returns 2.

(gcc49 (FreeBSD Ports Collection) 4.9.0 20130818 (experimental))


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/58275] __builtin_constant_p( expr ) returns true if expr is eliminated by CSE
  2013-08-29 19:40 [Bug c/58275] New: __builtin_constant_p( expr ) returns true if expr is eliminated by CSE tijl at coosemans dot org
@ 2013-08-29 19:46 ` glisse at gcc dot gnu.org
  2013-08-29 20:16 ` jakub at gcc dot gnu.org
  2013-08-29 20:33 ` tijl at coosemans dot org
  2 siblings, 0 replies; 4+ messages in thread
From: glisse at gcc dot gnu.org @ 2013-08-29 19:46 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58275

--- Comment #1 from Marc Glisse <glisse at gcc dot gnu.org> ---
Where do you see a bug? The test argc!=23 is always true in this branch, so it
*is* a compile-time constant. It is very much on purpose that
__builtin_constant_p returns true.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/58275] __builtin_constant_p( expr ) returns true if expr is eliminated by CSE
  2013-08-29 19:40 [Bug c/58275] New: __builtin_constant_p( expr ) returns true if expr is eliminated by CSE tijl at coosemans dot org
  2013-08-29 19:46 ` [Bug c/58275] " glisse at gcc dot gnu.org
@ 2013-08-29 20:16 ` jakub at gcc dot gnu.org
  2013-08-29 20:33 ` tijl at coosemans dot org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2013-08-29 20:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58275

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |jakub at gcc dot gnu.org
         Resolution|---                         |INVALID

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Yeah.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/58275] __builtin_constant_p( expr ) returns true if expr is eliminated by CSE
  2013-08-29 19:40 [Bug c/58275] New: __builtin_constant_p( expr ) returns true if expr is eliminated by CSE tijl at coosemans dot org
  2013-08-29 19:46 ` [Bug c/58275] " glisse at gcc dot gnu.org
  2013-08-29 20:16 ` jakub at gcc dot gnu.org
@ 2013-08-29 20:33 ` tijl at coosemans dot org
  2 siblings, 0 replies; 4+ messages in thread
From: tijl at coosemans dot org @ 2013-08-29 20:33 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58275

--- Comment #3 from Tijl Coosemans <tijl at coosemans dot org> ---
Eh, of course.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-29 20:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-29 19:40 [Bug c/58275] New: __builtin_constant_p( expr ) returns true if expr is eliminated by CSE tijl at coosemans dot org
2013-08-29 19:46 ` [Bug c/58275] " glisse at gcc dot gnu.org
2013-08-29 20:16 ` jakub at gcc dot gnu.org
2013-08-29 20:33 ` tijl at coosemans 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).