public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug sanitizer/110936] New: if constexpr: member function pointers cannot be checked with ubsan
@ 2023-08-07 15:52 jeanmichael.celerier at gmail dot com
  2023-09-01  1:54 ` [Bug c++/110936] " johelegp at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jeanmichael.celerier at gmail dot com @ 2023-08-07 15:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110936
           Summary: if constexpr: member function pointers cannot be
                    checked with ubsan
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jeanmichael.celerier at gmail dot com
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at gcc dot gnu.org
  Target Milestone: ---

Repro:

    struct foo {
      void bar() { }
    };

    void process(auto f) {
      if constexpr(&decltype(f)::bar);
    }

    int main() {
      process(foo{});
    }


Works fine in normal compilation mode as expected, however with
-fsanitize=undefined it does not work: https://gcc.godbolt.org/z/9qvz89na8

    <source>:6:3: error: '(foo::bar != 0)' is not a constant expression
      if constexpr(&decltype(f)::bar);

I tested as far back as g++ 7.1 and it did not work either back then, and prior
versions did not have if constexpr.

It would be less of a problem if there was any way to do #if
defined(__SANITIZE_UNDEFINED__) or something similar but while asan has it,
ubsan does not seem to have any macro to enable detection of it.

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

end of thread, other threads:[~2023-11-09  1:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 15:52 [Bug sanitizer/110936] New: if constexpr: member function pointers cannot be checked with ubsan jeanmichael.celerier at gmail dot com
2023-09-01  1:54 ` [Bug c++/110936] " johelegp at gmail dot com
2023-09-01  2:21 ` johelegp at gmail dot com
2023-11-09  1:42 ` nathanieloshead at gmail dot com
2023-11-09  1:44 ` johelegp 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).