public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98988] New: delete is not a constant expression with -fsanitize=undefined
@ 2021-02-07 22:13 david at doublewise dot net
  2021-02-08 15:29 ` [Bug c++/98988] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: david at doublewise dot net @ 2021-02-07 22:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98988
           Summary: delete is not a constant expression with
                    -fsanitize=undefined
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: david at doublewise dot net
  Target Milestone: ---

The following valid translation unit:

```
constexpr bool f() {
        auto ptr = new int();
        delete ptr;
        return true;
}

static_assert(f());
```

is incorrectly rejected when compiled with `-fsanitize=undefined`, complaining
about

```
<source>:7:16: error: non-constant condition for static assertion
    7 | static_assert(f());
      |               ~^~
<source>:7:16:   in 'constexpr' expansion of 'f()'
<source>:3:9: error: '(((int*)(& heap )) != 0)' is not a constant expression
    3 |         delete ptr;
      |         ^~~~~~~~~~
Compiler returned: 1
```

See it live: https://godbolt.org/z/Yf67G7

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

end of thread, other threads:[~2021-03-19 23:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-07 22:13 [Bug c++/98988] New: delete is not a constant expression with -fsanitize=undefined david at doublewise dot net
2021-02-08 15:29 ` [Bug c++/98988] " jakub at gcc dot gnu.org
2021-02-10 18:32 ` cvs-commit at gcc dot gnu.org
2021-02-10 18:48 ` jakub at gcc dot gnu.org
2021-03-19 23:28 ` cvs-commit 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).