Skip to content

Clang incorrectly rejects getting address of conditionally noexcept function in a nested class template #81962

Open
@mingxwa

Description

@mingxwa

Accepted by VS 2022 17.10 Preview 1, GCC 13.2, rejected by Clang 17.0.6.

template <bool NE>
struct Foo {
  template <class D>
  static void Fun() noexcept(NE) {}
};

int main() {
  using F = decltype(&Foo<true>::Fun<int>);
  F f{&Foo<true>::Fun<int>};
}

Output from clang-cl /EHsc /nologo /W4 /std:c++latest /c test.cpp:

test.cpp:9:8: error: address of overloaded function 'Fun' does not match required type 'void () noexcept'
    9 |   F f{&Foo<true>::Fun<int>};
      |        ^~~~~~~~~~~~~~~~~~~
test.cpp:4:15: note: candidate template ignored: could not match 'void ()' against 'void () noexcept'
    4 |   static void Fun() noexcept(NE) {}
      |               ^
1 error generated.

Output from clang-cl -v:

clang version 17.0.6
Target: x86_64-pc-windows-msvc
Thread model: posix

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"rejects-valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions