public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96672] New: Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site
@ 2020-08-18  9:07 felix.von.s at posteo dot de
  2020-08-18 11:21 ` [Bug tree-optimization/96672] " amonakov at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: felix.von.s at posteo dot de @ 2020-08-18  9:07 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 96672
           Summary: Missing -Wclobbered diagnostic, or:
                    __attribute__((returns_twice)) does not inhibit
                    constant folding across call site
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix.von.s at posteo dot de
  Target Milestone: ---

Created attachment 49072
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49072&action=edit
Sample program

The attached sample, compiled with -O3 -DVOLATILE= outputs 5; without either
flag it outputs 6.

I expected at least one of the following:

- that the compiler warn about the clobbered x variable at the return
statement;
- that the program output 6 whether or not x is declared volatile.

Currently neither is the case; compiling with -Wall -Wextra -Wclobbered emits
no warnings. While the standard mandates that the variable be declared
volatile, GCC seems to make some effort to preserve the expected semantics even
when this requirement is not met; this would seem like a missed case.

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

* [Bug tree-optimization/96672] Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site
  2020-08-18  9:07 [Bug tree-optimization/96672] New: Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site felix.von.s at posteo dot de
@ 2020-08-18 11:21 ` amonakov at gcc dot gnu.org
  2020-08-25 10:45 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: amonakov at gcc dot gnu.org @ 2020-08-18 11:21 UTC (permalink / raw)
  To: gcc-bugs

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

Alexander Monakov <amonakov at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amonakov at gcc dot gnu.org

--- Comment #1 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Looking at dumps, after expanding to RTL we do not have the abnormal edge from
the longjmp BB. So while on GIMPLE we preserve modifications of 'x', on RTL we
see the 'x = 6' write as dead, and the 'x = 5' write is propagated to the use.

(the -Wclobbered warning happens after all the propagation is done)

I am surprised the abnormal dispatcher block is not preserved on RTL.

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

* [Bug tree-optimization/96672] Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site
  2020-08-18  9:07 [Bug tree-optimization/96672] New: Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site felix.von.s at posteo dot de
  2020-08-18 11:21 ` [Bug tree-optimization/96672] " amonakov at gcc dot gnu.org
@ 2020-08-25 10:45 ` rguenth at gcc dot gnu.org
  2020-08-31  1:04 ` pinskia at gcc dot gnu.org
  2024-04-13 23:00 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 10:45 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|                            |2020-08-25

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
abnormal edges are "rebuilt" during RTL expansion, we have a duplicate
somewhere for this correctness bug.

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

* [Bug tree-optimization/96672] Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site
  2020-08-18  9:07 [Bug tree-optimization/96672] New: Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site felix.von.s at posteo dot de
  2020-08-18 11:21 ` [Bug tree-optimization/96672] " amonakov at gcc dot gnu.org
  2020-08-25 10:45 ` rguenth at gcc dot gnu.org
@ 2020-08-31  1:04 ` pinskia at gcc dot gnu.org
  2024-04-13 23:00 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-08-31  1:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely the patch which moves the warning to gimple would help here:
https://gcc.gnu.org/pipermail/gcc-patches/2019-October/530995.html

But I have not seen any movement on it since last year but I could be wrong.

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

* [Bug tree-optimization/96672] Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site
  2020-08-18  9:07 [Bug tree-optimization/96672] New: Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site felix.von.s at posteo dot de
                   ` (2 preceding siblings ...)
  2020-08-31  1:04 ` pinskia at gcc dot gnu.org
@ 2024-04-13 23:00 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-04-13 23:00 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |57067

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> abnormal edges are "rebuilt" during RTL expansion, we have a duplicate
> somewhere for this correctness bug.

PR 57067


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57067
[Bug 57067] Missing control flow edges for setjmp/longjmp

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

end of thread, other threads:[~2024-04-13 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18  9:07 [Bug tree-optimization/96672] New: Missing -Wclobbered diagnostic, or: __attribute__((returns_twice)) does not inhibit constant folding across call site felix.von.s at posteo dot de
2020-08-18 11:21 ` [Bug tree-optimization/96672] " amonakov at gcc dot gnu.org
2020-08-25 10:45 ` rguenth at gcc dot gnu.org
2020-08-31  1:04 ` pinskia at gcc dot gnu.org
2024-04-13 23:00 ` pinskia 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).