public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97145] New: Sanitizer pointer-subtract breaks constexpr functions subtracting pointers
@ 2020-09-21 11:55 chfast at gmail dot com
  2020-09-21 12:09 ` [Bug c++/97145] " rguenth at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: chfast at gmail dot com @ 2020-09-21 11:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97145
           Summary: Sanitizer pointer-subtract breaks constexpr functions
                    subtracting pointers
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chfast at gmail dot com
  Target Milestone: ---

Having a constexpr function that subtracts two pointers does not work in
constexpr context when building with -fsanitize=address,pointer-subtract.

GCC version: starts with 8.1 where pointer-subtract was introduced, up to
trunk.

Minimal code:

constexpr char* a = nullptr;
constexpr auto d = a - a;

<source>:3:22: error: '__builtin___sanitizer_ptr_sub(0, 0)' is not a constant
expression

    3 | constexpr auto d = a - a;

      |                    ~~^~~

https://godbolt.org/z/qWxT9v

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

end of thread, other threads:[~2021-02-23 17:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 11:55 [Bug c++/97145] New: Sanitizer pointer-subtract breaks constexpr functions subtracting pointers chfast at gmail dot com
2020-09-21 12:09 ` [Bug c++/97145] " rguenth at gcc dot gnu.org
2020-09-21 12:12 ` jakub at gcc dot gnu.org
2020-09-21 15:47 ` jakub at gcc dot gnu.org
2020-09-22 19:08 ` cvs-commit at gcc dot gnu.org
2020-10-05  8:24 ` cvs-commit at gcc dot gnu.org
2021-02-23 17:34 ` chfast at gmail dot com

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).