public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/102603] New: Compile-time evaluation of indirection via dangling pointer is not rejected
@ 2021-10-05  8:19 fchelnokov at gmail dot com
  2021-10-05 14:15 ` [Bug c++/102603] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: fchelnokov at gmail dot com @ 2021-10-05  8:19 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 102603
           Summary: Compile-time evaluation of indirection via dangling
                    pointer is not rejected
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fchelnokov at gmail dot com
  Target Milestone: ---

The program as follows is ill-formed:
```
constexpr bool g() {
    int * p = nullptr;
    {
        int c = 0;
        p = &c;
    }
    return *p == 0; //indirection via dangling pointer
};

int main() {
    static_assert( g() );
}
```
but GCC erroneously accepts it, demo: https://gcc.godbolt.org/z/8xE7csGKo

The compiler must fail the program, see stackoverflow explanation:
https://stackoverflow.com/a/69446660/7325599

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

* [Bug c++/102603] Compile-time evaluation of indirection via dangling pointer is not rejected
  2021-10-05  8:19 [Bug c++/102603] New: Compile-time evaluation of indirection via dangling pointer is not rejected fchelnokov at gmail dot com
@ 2021-10-05 14:15 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-10-05 14:15 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 70331.

*** This bug has been marked as a duplicate of bug 70331 ***

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

end of thread, other threads:[~2021-10-05 14:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05  8:19 [Bug c++/102603] New: Compile-time evaluation of indirection via dangling pointer is not rejected fchelnokov at gmail dot com
2021-10-05 14:15 ` [Bug c++/102603] " 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).