public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/103780] New: zero pointer is considered true @ 2021-12-20 19:51 lucfety at gmail dot com 2021-12-20 20:03 ` [Bug c++/103780] " pinskia at gcc dot gnu.org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: lucfety at gmail dot com @ 2021-12-20 19:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103780 Bug ID: 103780 Summary: zero pointer is considered true Product: gcc Version: 10.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lucfety at gmail dot com Target Milestone: --- Created attachment 52036 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52036&action=edit gcc-10 -v -save-temps -o main -O2 main.ii f.ii Under certain conditions (see the code for example), a pointer that goes to 0 after decrement is still considered true. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103780] zero pointer is considered true 2021-12-20 19:51 [Bug c++/103780] New: zero pointer is considered true lucfety at gmail dot com @ 2021-12-20 20:03 ` pinskia at gcc dot gnu.org 2021-12-20 20:59 ` redi at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2021-12-20 20:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103780 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- >a pointer that goes to 0 after decrement is still considered true. Yes a pointer is never a null pointer if it is decremented and it was a valid pointer to begin with. Use -fno-delete-null-pointer-checks if you want to disable this optimization. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103780] zero pointer is considered true 2021-12-20 19:51 [Bug c++/103780] New: zero pointer is considered true lucfety at gmail dot com 2021-12-20 20:03 ` [Bug c++/103780] " pinskia at gcc dot gnu.org @ 2021-12-20 20:59 ` redi at gcc dot gnu.org 2021-12-20 21:51 ` lucfety at gmail dot com ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: redi at gcc dot gnu.org @ 2021-12-20 20:59 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103780 --- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- It is undefined to decrement a pointer to point before an object. ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103780] zero pointer is considered true 2021-12-20 19:51 [Bug c++/103780] New: zero pointer is considered true lucfety at gmail dot com 2021-12-20 20:03 ` [Bug c++/103780] " pinskia at gcc dot gnu.org 2021-12-20 20:59 ` redi at gcc dot gnu.org @ 2021-12-20 21:51 ` lucfety at gmail dot com 2021-12-20 22:03 ` schwab@linux-m68k.org 2021-12-21 9:34 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: lucfety at gmail dot com @ 2021-12-20 21:51 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103780 Luc FETY <lucfety at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|INVALID |FIXED --- Comment #3 from Luc FETY <lucfety at gmail dot com> --- (In reply to Andrew Pinski from comment #1) > >a pointer that goes to 0 after decrement is still considered true. > > Yes a pointer is never a null pointer if it is decremented and it was a > valid pointer to begin with. > > Use -fno-delete-null-pointer-checks if you want to disable this optimization. The code shows 2 cases: 1) a pointer decremented to zero is true 2) a pointer decremented to zero is false Bizare ... Thank you for seeing the code. -fno-delete-null-pointer-checks seems to fix indetermination Thank you ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103780] zero pointer is considered true 2021-12-20 19:51 [Bug c++/103780] New: zero pointer is considered true lucfety at gmail dot com ` (2 preceding siblings ...) 2021-12-20 21:51 ` lucfety at gmail dot com @ 2021-12-20 22:03 ` schwab@linux-m68k.org 2021-12-21 9:34 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: schwab@linux-m68k.org @ 2021-12-20 22:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103780 Andreas Schwab <schwab@linux-m68k.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |INVALID ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/103780] zero pointer is considered true 2021-12-20 19:51 [Bug c++/103780] New: zero pointer is considered true lucfety at gmail dot com ` (3 preceding siblings ...) 2021-12-20 22:03 ` schwab@linux-m68k.org @ 2021-12-21 9:34 ` redi at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: redi at gcc dot gnu.org @ 2021-12-21 9:34 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103780 --- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> --- Yes that's the nature of undefined behaviour. It might have surprising results. Don't write code with undefined behaviour. The FIXED resolution means a bug in GCC was fixed, not that your problem has been solved. Please don't change it to FIXED, because nothing was changed in GCC, there was no bug to fix. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2021-12-21 9:34 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-12-20 19:51 [Bug c++/103780] New: zero pointer is considered true lucfety at gmail dot com 2021-12-20 20:03 ` [Bug c++/103780] " pinskia at gcc dot gnu.org 2021-12-20 20:59 ` redi at gcc dot gnu.org 2021-12-20 21:51 ` lucfety at gmail dot com 2021-12-20 22:03 ` schwab@linux-m68k.org 2021-12-21 9:34 ` redi 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).