-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[clang-cl] The [[noreturn]]
attribute causes parsing to crash by declaring a concurrent function that returns.
#127327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Reduced to namespace std {
template <class = void> struct coroutine_handle {
static constexpr coroutine_handle from_address(void *const) noexcept {
return {};
}
constexpr operator coroutine_handle<>() const noexcept { return {}; }
};
struct suspend_always {
bool await_ready() noexcept { return false; }
void await_suspend(coroutine_handle<>) noexcept {}
void await_resume() noexcept {}
};
template <class _Ret, class...>
struct coroutine_traits {
using promise_type = typename _Ret::promise_type;
};
} // namespace std
struct promise;
struct awaitable {
bool await_ready() { return false; }
void await_suspend(std::coroutine_handle<>) {}
void await_resume() {}
};
struct coroutine : std::coroutine_handle<> {
using promise_type = promise;
};
struct promise {
coroutine get_return_object() { return {}; }
std::suspend_always initial_suspend() noexcept { return {}; }
std::suspend_always final_suspend() noexcept { return {}; }
void return_void() {}
void unhandled_exception() {}
};
[[noreturn]] coroutine f() { co_await awaitable{}; } Coroutines don't have diagnostic IDs set when A simple fix would be to use the same diagnostics as for functions. This would, however, generate two warnings:
The first warning, also visible in the current output, is emitted when building the return statement, which discovers that the function is I'd fix this, but would like to know if there is any preference for the diagnostic (i.e. should it be omitted or more descriptive - in this case we know that the function is a coroutine). |
@llvm/issue-subscribers-clang-frontend Author: YuHuanTin (YuHuanTin)
```
D:\LLVM\bin\clang-cl.exe -TP -DCRCPP_IMPORT_API -imsvcD:\Clion\vcpkg\installed\x64-windows\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /clang:-Wall -Wextra -Wpedantic -Wconversion /permissive- /showIncludes /FoCMakeFiles\New.dir\main.cpp.obj /FdCMakeFiles\New.dir\ -c -- D:\Clion\Project\New\main.cpp
D:\Clion\Project\New\main.cpp(7,41): warning: function 'foo' declared 'noreturn' should not return [-Winvalid-noreturn]
7 | [[noreturn]] concurrencpp::result<void> foo() {
| ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: D:\\LLVM\\bin\\clang-cl.exe -TP -DCRCPP_IMPORT_API -imsvcD:\\Clion\\vcpkg\\installed\\x64-windows\\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /clang:-Wall -Wextra -Wpedantic -Wconversion /permissive- /showIncludes /FoCMakeFiles\\New.dir\\main.cpp.obj /FdCMakeFiles\\New.dir\\ -c -- D:\\Clion\\Project\\New\\main.cpp
1. <eof> parser at end of file
2. D:\Clion\Project\New\main.cpp:7:47: parsing function body 'foo'
Exception Code: 0xC0000005
#0 0x00007ff7e22fcd44 (D:\LLVM\bin\clang-cl.exe+0x77cd44)
#1 0x00007ff7e22fcb30 (D:\LLVM\bin\clang-cl.exe+0x77cb30)
#2 0x00007ff7e3a2cf6f (D:\LLVM\bin\clang-cl.exe+0x1eacf6f)
#3 0x00007ff7e2c95037 (D:\LLVM\bin\clang-cl.exe+0x1115037)
#4 0x00007ff7e2c9433a (D:\LLVM\bin\clang-cl.exe+0x111433a)
#5 0x00007ff7e2c93e83 (D:\LLVM\bin\clang-cl.exe+0x1113e83)
#6 0x00007ff7e2c90eb5 (D:\LLVM\bin\clang-cl.exe+0x1110eb5)
#7 0x00007ff7e2c90e2a (D:\LLVM\bin\clang-cl.exe+0x1110e2a)
#8 0x00007ff7e2d41fa8 (D:\LLVM\bin\clang-cl.exe+0x11c1fa8)
#9 0x00007ff7e2c82167 (D:\LLVM\bin\clang-cl.exe+0x1102167)
#10 0x00007ff7e2c7f6b4 (D:\LLVM\bin\clang-cl.exe+0x10ff6b4)
#11 0x00007ff7e2c76d59 (D:\LLVM\bin\clang-cl.exe+0x10f6d59)
#12 0x00007ff7e2ae8ea5 (D:\LLVM\bin\clang-cl.exe+0xf68ea5)
#13 0x00007ff7e2ae0c12 (D:\LLVM\bin\clang-cl.exe+0xf60c12)
#14 0x00007ff7e2add88a (D:\LLVM\bin\clang-cl.exe+0xf5d88a)
#15 0x00007ff7e36e09e6 (D:\LLVM\bin\clang-cl.exe+0x1b609e6)
#16 0x00007ff7e36e064e (D:\LLVM\bin\clang-cl.exe+0x1b6064e)
#17 0x00007ff7e2143a61 (D:\LLVM\bin\clang-cl.exe+0x5c3a61)
#18 0x00007ff7e21435f2 (D:\LLVM\bin\clang-cl.exe+0x5c35f2)
#19 0x00007ff7e2140366 (D:\LLVM\bin\clang-cl.exe+0x5c0366)
#20 0x00007ff7e213d325 (D:\LLVM\bin\clang-cl.exe+0x5bd325)
#21 0x00007ff7e213bcbe (D:\LLVM\bin\clang-cl.exe+0x5bbcbe)
#22 0x00007ff7e28555cd (D:\LLVM\bin\clang-cl.exe+0xcd55cd)
#23 0x00007ff7e22c4175 (D:\LLVM\bin\clang-cl.exe+0x744175)
#24 0x00007ff7e22c3f68 (D:\LLVM\bin\clang-cl.exe+0x743f68)
#25 0x00007ff7e1fcc0c8 (D:\LLVM\bin\clang-cl.exe+0x44c0c8)
#26 0x00007ff7e1fcb44e (D:\LLVM\bin\clang-cl.exe+0x44b44e)
#27 0x00007ff7e1fcafc7 (D:\LLVM\bin\clang-cl.exe+0x44afc7)
#28 0x00007ff7e1fc2756 (D:\LLVM\bin\clang-cl.exe+0x442756)
#29 0x00007ff7e1fbfed3 (D:\LLVM\bin\clang-cl.exe+0x43fed3)
#30 0x00007ff7e3782bc8 (D:\LLVM\bin\clang-cl.exe+0x1c02bc8)
#31 0x00007ffbdf6b7374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#32 0x00007ffbe135cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.1.7
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\LLVM\bin
clang-cl: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: ninja: build stopped: subcommand failed.
Yes, I know it's a bad practice to flag the crash file |
@llvm/issue-subscribers-coroutines Author: YuHuanTin (YuHuanTin)
```
D:\LLVM\bin\clang-cl.exe -TP -DCRCPP_IMPORT_API -imsvcD:\Clion\vcpkg\installed\x64-windows\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /clang:-Wall -Wextra -Wpedantic -Wconversion /permissive- /showIncludes /FoCMakeFiles\New.dir\main.cpp.obj /FdCMakeFiles\New.dir\ -c -- D:\Clion\Project\New\main.cpp
D:\Clion\Project\New\main.cpp(7,41): warning: function 'foo' declared 'noreturn' should not return [-Winvalid-noreturn]
7 | [[noreturn]] concurrencpp::result<void> foo() {
| ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: D:\\LLVM\\bin\\clang-cl.exe -TP -DCRCPP_IMPORT_API -imsvcD:\\Clion\\vcpkg\\installed\\x64-windows\\include /DWIN32 /D_WINDOWS /EHsc /Ob0 /Od /RTC1 -std:c++latest -MDd -Zi /clang:-Wall -Wextra -Wpedantic -Wconversion /permissive- /showIncludes /FoCMakeFiles\\New.dir\\main.cpp.obj /FdCMakeFiles\\New.dir\\ -c -- D:\\Clion\\Project\\New\\main.cpp
1. <eof> parser at end of file
2. D:\Clion\Project\New\main.cpp:7:47: parsing function body 'foo'
Exception Code: 0xC0000005
#0 0x00007ff7e22fcd44 (D:\LLVM\bin\clang-cl.exe+0x77cd44)
#1 0x00007ff7e22fcb30 (D:\LLVM\bin\clang-cl.exe+0x77cb30)
#2 0x00007ff7e3a2cf6f (D:\LLVM\bin\clang-cl.exe+0x1eacf6f)
#3 0x00007ff7e2c95037 (D:\LLVM\bin\clang-cl.exe+0x1115037)
#4 0x00007ff7e2c9433a (D:\LLVM\bin\clang-cl.exe+0x111433a)
#5 0x00007ff7e2c93e83 (D:\LLVM\bin\clang-cl.exe+0x1113e83)
#6 0x00007ff7e2c90eb5 (D:\LLVM\bin\clang-cl.exe+0x1110eb5)
#7 0x00007ff7e2c90e2a (D:\LLVM\bin\clang-cl.exe+0x1110e2a)
#8 0x00007ff7e2d41fa8 (D:\LLVM\bin\clang-cl.exe+0x11c1fa8)
#9 0x00007ff7e2c82167 (D:\LLVM\bin\clang-cl.exe+0x1102167)
#10 0x00007ff7e2c7f6b4 (D:\LLVM\bin\clang-cl.exe+0x10ff6b4)
#11 0x00007ff7e2c76d59 (D:\LLVM\bin\clang-cl.exe+0x10f6d59)
#12 0x00007ff7e2ae8ea5 (D:\LLVM\bin\clang-cl.exe+0xf68ea5)
#13 0x00007ff7e2ae0c12 (D:\LLVM\bin\clang-cl.exe+0xf60c12)
#14 0x00007ff7e2add88a (D:\LLVM\bin\clang-cl.exe+0xf5d88a)
#15 0x00007ff7e36e09e6 (D:\LLVM\bin\clang-cl.exe+0x1b609e6)
#16 0x00007ff7e36e064e (D:\LLVM\bin\clang-cl.exe+0x1b6064e)
#17 0x00007ff7e2143a61 (D:\LLVM\bin\clang-cl.exe+0x5c3a61)
#18 0x00007ff7e21435f2 (D:\LLVM\bin\clang-cl.exe+0x5c35f2)
#19 0x00007ff7e2140366 (D:\LLVM\bin\clang-cl.exe+0x5c0366)
#20 0x00007ff7e213d325 (D:\LLVM\bin\clang-cl.exe+0x5bd325)
#21 0x00007ff7e213bcbe (D:\LLVM\bin\clang-cl.exe+0x5bbcbe)
#22 0x00007ff7e28555cd (D:\LLVM\bin\clang-cl.exe+0xcd55cd)
#23 0x00007ff7e22c4175 (D:\LLVM\bin\clang-cl.exe+0x744175)
#24 0x00007ff7e22c3f68 (D:\LLVM\bin\clang-cl.exe+0x743f68)
#25 0x00007ff7e1fcc0c8 (D:\LLVM\bin\clang-cl.exe+0x44c0c8)
#26 0x00007ff7e1fcb44e (D:\LLVM\bin\clang-cl.exe+0x44b44e)
#27 0x00007ff7e1fcafc7 (D:\LLVM\bin\clang-cl.exe+0x44afc7)
#28 0x00007ff7e1fc2756 (D:\LLVM\bin\clang-cl.exe+0x442756)
#29 0x00007ff7e1fbfed3 (D:\LLVM\bin\clang-cl.exe+0x43fed3)
#30 0x00007ff7e3782bc8 (D:\LLVM\bin\clang-cl.exe+0x1c02bc8)
#31 0x00007ffbdf6b7374 (C:\Windows\System32\KERNEL32.DLL+0x17374)
#32 0x00007ffbe135cc91 (C:\Windows\SYSTEM32\ntdll.dll+0x4cc91)
clang-cl: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 19.1.7
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: D:\LLVM\bin
clang-cl: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT: ninja: build stopped: subcommand failed.
Yes, I know it's a bad practice to flag the crash file |
Declaring a coroutine `[[noreturn]]` doesn't make sense, because it will always return its handle. Clang previously crashed when trying to warn about this (diagnostic ID was 0). Fixes llvm#127327.
The full code
Yes, I know it's a bad practice to flag
[[noreturn]]
on a function that might return, but it should get a warn or error, but the compiler crashesthe crash file
crash.zip
The text was updated successfully, but these errors were encountered: