llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.9k stars 11.51k forks source link

[Clang][C++11] `decltype` does not strip `noexcept` and cannot form double pointers to noexcept functions #101687

Open MitalAshok opened 1 month ago

MitalAshok commented 1 month ago

https://godbolt.org/z/a7Ebf5f8M

void f() noexcept;
decltype(f)** p = nullptr;
decltype(&f)* q = nullptr;
<source>:2:15: error: exception specifications are not allowed beyond a single level of indirection
    2 | decltype(f)** p = nullptr;
      |               ^
<source>:3:15: error: exception specifications are not allowed beyond a single level of indirection
    3 | decltype(&f)* q = nullptr;
      |               ^

(A similar error with __typeof__/__typeof_unqual__)

llvmbot commented 1 month ago

@llvm/issue-subscribers-clang-frontend

Author: Mital Ashok (MitalAshok)

https://godbolt.org/z/a7Ebf5f8M ```c++ void f() noexcept; decltype(f)** p = nullptr; decltype(&f)* q = nullptr; ``` ``` <source>:2:15: error: exception specifications are not allowed beyond a single level of indirection 2 | decltype(f)** p = nullptr; | ^ <source>:3:15: error: exception specifications are not allowed beyond a single level of indirection 3 | decltype(&f)* q = nullptr; | ^ ``` (A similar error with `__typeof__`/`__typeof_unqual__`)
shafik commented 1 month ago

See cwg92 and N4320

shafik commented 1 month ago

CC @Endilll

zygoloid commented 1 month ago

In C++17 onwards, noexcept specifications are part of the type system, but we should not look for them in type sugar through decltype and friends in C++14 and before.