Skip to content
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

Unreachable code warning compiling under MSVC with LTO #1493

Open
jcmoyer opened this issue May 25, 2023 · 0 comments
Open

Unreachable code warning compiling under MSVC with LTO #1493

jcmoyer opened this issue May 25, 2023 · 0 comments

Comments

@jcmoyer
Copy link

jcmoyer commented May 25, 2023

In my setup I'm compiling Lua as part of my project, and when I turn on LTO via CMAKE_INTERPROCEDURAL_OPTIMIZATION, the return listed below is considered unreachable by MSVC. I guess MSVC can analyze through multiple Lua calls and determine that luaL_error eventually calls a function marked noreturn. I'm compiling with /W4 /WX and this becomes an error during linking, so marking the library as SYSTEM in cmake doesn't suppress the error. Commenting out the return fixes the issue in MSVC, but I don't know if it'll break other compilers.

Tested with Sol 3.3.0, Lua 5.4.4, cl 19.36.32532 x64.

Sol config: SOL_USING_CXX_LUA, SOL_ALL_SAFETIES_ON, SOL_CHECK_ARGUMENTS

if (!result) {
if (pointer_adjusted == nullptr) {
luaL_error(L, "aligned allocation of userdata block (pointer section) for '%s' failed", detail::demangle<T>().c_str());
}
else {
luaL_error(L, "aligned allocation of userdata block (data section) for '%s' failed", detail::demangle<T>().c_str());
}
return nullptr;
}

I can try to provide a complete test case if necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant