public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ipa/61159] New: __builtin_constant_p gives incorrect results with aliases
@ 2014-05-12 18:07 bugdal at aerifal dot cx
  2014-05-12 19:40 ` [Bug ipa/61159] " bugdal at aerifal dot cx
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: bugdal at aerifal dot cx @ 2014-05-12 18:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61159
           Summary: __builtin_constant_p gives incorrect results with
                    aliases
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bugdal at aerifal dot cx

This issue is closely related to #61144, but seems to have appeared earlier.
Consider the following test case:

static int dummy = 0;
extern int foo __attribute__((__weak__, __alias__("dummy")));
typedef char check[2*!__builtin_constant_p(dummy)-1];
typedef char check[2*!__builtin_constant_p(foo)-1];

While the static dummy could be considered constant if its address did not leak
outside the translation unit, its address DOES leak via the weak alias foo. As
long as there is no strong definition for foo in another translation unit,
dummy may be externally modified via the alias foo. As for foo, it is external
and thus may never be considered constant. Thus, __builtin_constant_p(dummy)
and __builtin_constant_p(foo) should both yield zero and the above translation
unit should compile successfully.

The results observed vary highly with gcc version. A number of versions were
observed giving __builtin_constant_p(dummy)==1, including 4.8.1, but
__builtin_constant_p(foo) was more rare, showing up only in 4.9.0 and some
really old versions like 4.4.7 (tested via gcc.godbolt.org since I don't have
that many gcc versions lying around to test locally).


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

* [Bug ipa/61159] __builtin_constant_p gives incorrect results with aliases
  2014-05-12 18:07 [Bug ipa/61159] New: __builtin_constant_p gives incorrect results with aliases bugdal at aerifal dot cx
@ 2014-05-12 19:40 ` bugdal at aerifal dot cx
  2024-02-26  9:42 ` cvs-commit at gcc dot gnu.org
  2024-02-26  9:45 ` ro at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: bugdal at aerifal dot cx @ 2014-05-12 19:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Rich Felker <bugdal at aerifal dot cx> ---
I should amend this report with further info: __builtin_constant_p is giving
different results for dummy and foo depending on whether it's used at file
scope or in a function. I've also observed some other really weird behavior
from it that I need to summarize and report.


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

* [Bug ipa/61159] __builtin_constant_p gives incorrect results with aliases
  2014-05-12 18:07 [Bug ipa/61159] New: __builtin_constant_p gives incorrect results with aliases bugdal at aerifal dot cx
  2014-05-12 19:40 ` [Bug ipa/61159] " bugdal at aerifal dot cx
@ 2024-02-26  9:42 ` cvs-commit at gcc dot gnu.org
  2024-02-26  9:45 ` ro at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-26  9:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61159

--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <ro@gcc.gnu.org>:

https://gcc.gnu.org/g:a25d7d1385087e0f43574064db45f1bc7d52f400

commit r14-9176-ga25d7d1385087e0f43574064db45f1bc7d52f400
Author: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Date:   Mon Feb 26 10:42:04 2024 +0100

    testsuite: xfail gcc.c-torture/compile/pr61159.c on Solaris/x86 with as
[PR61159]

    gcc.c-torture/compile/pr61159.c currently FAILs on 32 and 64-bit
    Solaris/x86 with the native assembler:

    FAIL: gcc.c-torture/compile/pr61159.c   -O0  (test for excess errors)
    FAIL: gcc.c-torture/compile/pr61159.c   -O1  (test for excess errors)
    FAIL: gcc.c-torture/compile/pr61159.c   -O2  (test for excess errors)
    FAIL: gcc.c-torture/compile/pr61159.c   -O2 -flto  (test for excess errors)
    FAIL: gcc.c-torture/compile/pr61159.c   -O2 -flto -flto-partition=none 
(test for excess errors)
    FAIL: gcc.c-torture/compile/pr61159.c   -O3 -g  (test for excess errors)
    FAIL: gcc.c-torture/compile/pr61159.c   -Os  (test for excess errors)

    Excess errors:
    Assembler: pr61159.c
            "/var/tmp//ccRtFPva.s", line 5 : Cannot set a weak symbol to a
common symbol

    This is a bug/limitation in the native assembler.  Given that this
    hasn't seen fixes for a long time, this patch xfails the test.

    Tested on i386-pc-solaris2.11 (as and gas) and x86_64-pc-linux-gnu.

    2024-02-24  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

            gcc/testsuite:
            PR ipa/61159
            * gcc.c-torture/compile/pr61159.c: xfail on Solaris/x86 with as.

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

* [Bug ipa/61159] __builtin_constant_p gives incorrect results with aliases
  2014-05-12 18:07 [Bug ipa/61159] New: __builtin_constant_p gives incorrect results with aliases bugdal at aerifal dot cx
  2014-05-12 19:40 ` [Bug ipa/61159] " bugdal at aerifal dot cx
  2024-02-26  9:42 ` cvs-commit at gcc dot gnu.org
@ 2024-02-26  9:45 ` ro at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: ro at gcc dot gnu.org @ 2024-02-26  9:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61159

Rainer Orth <ro at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|hubicka at gcc dot gnu.org         |ro at gcc dot gnu.org
   Target Milestone|---                         |14.0
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2024-Februar
                   |                            |y/646514.html
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #9 from Rainer Orth <ro at gcc dot gnu.org> ---
Test xfail'ed on Solaris/x86 with as for GCC 14.0.1.

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

end of thread, other threads:[~2024-02-26  9:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-12 18:07 [Bug ipa/61159] New: __builtin_constant_p gives incorrect results with aliases bugdal at aerifal dot cx
2014-05-12 19:40 ` [Bug ipa/61159] " bugdal at aerifal dot cx
2024-02-26  9:42 ` cvs-commit at gcc dot gnu.org
2024-02-26  9:45 ` ro 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).