public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/99235] New: Null pointer check incorrectly deleted for static pointer
@ 2021-02-24 3:20 sebastianquilter at gmail dot com
2021-02-24 3:59 ` [Bug tree-optimization/99235] " pinskia at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: sebastianquilter at gmail dot com @ 2021-02-24 3:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99235
Bug ID: 99235
Summary: Null pointer check incorrectly deleted for static
pointer
Product: gcc
Version: 10.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: sebastianquilter at gmail dot com
Target Milestone: ---
int main()
{
static char* ptr = (char*)1;
--ptr;
if(ptr){
return 1;
}
return 0;
}
Compiled with -O0, it returns 0
Compiled with -O1, it returns 1
Compiled with -O1 -fno-delete-null-pointer-checks, it returns 0
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/99235] Null pointer check incorrectly deleted for static pointer
2021-02-24 3:20 [Bug tree-optimization/99235] New: Null pointer check incorrectly deleted for static pointer sebastianquilter at gmail dot com
@ 2021-02-24 3:59 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-02-24 3:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99235
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> ---
Once a pointer is "valid", it can never become a null pointer if decremented or
incremented. So this code is undefined and GCC is doing an ok thing to do.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-24 3:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 3:20 [Bug tree-optimization/99235] New: Null pointer check incorrectly deleted for static pointer sebastianquilter at gmail dot com
2021-02-24 3:59 ` [Bug tree-optimization/99235] " 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).