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.