Comments (5)
Wait, I'm stupid. Sorry, realized the actual reason just now.
Yes, it fails even for me. The key was that CMAKE_BUILD_TYPE
is unset by default, and ... tests for the CORRADE_DEBUG_ASSERT()
macro don't handle that case properly, expecting either NDEBUG
or CORRADE_IS_DEBUG_BUILD
being set, and there's neither if CMAKE_BUILD_TYPE
is empty. The AssertDisabledTest
then passes a failing statement to the assert macro to test it's indeed not doing anything, which in turn means that a constexpr
variable is not initialized by a constexpr
statement (as that's how the assert failure manifests at compile time).
TL;DR: if you build with -DCMAKE_BUILD_TYPE=Release
or Debug
, it'll go through. Working on a proper fix now, apologies for assuming it's your toolchain being cursed and not my code being stupid.
from corrade.
Should be fixed with 1fea951, sorry again :)
from corrade.
And with clang++:
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix
another constexpr-related error:
[ 63%] Building CXX object src/Corrade/Utility/Test/CMakeFiles/UtilityDebugAssertDisabledTest.dir/AssertDisabledTest.cpp.o
/home/cmey/Code/cpp/wonderland_repos/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:136:23: error: constexpr variable 'three' must be initialized by a constant expression
constexpr int three = divide(15, 0);
^ ~~~~~~~~~~~~~
/home/cmey/Code/cpp/wonderland_repos/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:123:12: note: non-literal type '(lambda at /home/cmey/Code/cpp/wonderland_repos/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:123:12)' cannot be used in a constant expression
return TESTED_CONSTEXPR_ASSERT(b, "b can't be zero"), a/(b + 5);
from corrade.
Heh... unpossible. This has worked for ages on all compilers back to Clang 3.8, GCC 4.8 and MSVC 2015.
Both the GCC and the Clang error is about the same thing, a lambda that gets called if an expression fails. Which is a valid technique explained in this post from 2017. I don't know where the GCC error originates from, but I suspect it would be from AssertDisabledTest.cpp as well, since that's where this macro is mainly tested?
Like with #135, I have a suspicion there's something seriously broken with the toolchain you use 😅
from corrade.
The compilation error is reproducible in a clean Docker environment (docker run -it ubuntu:22.04
) using clang-11, clang-12, clang-13, clang-14, and gcc-11 (haven't tried more) and also reproducible in archlinux docker image (docker run -it archlinux
) using gcc:
[root@0e7cc222fbdc build]# cmake -DBUILD_TESTS=ON ../
-- The CXX compiler identification is GNU 12.1.0
[root@0e7cc222fbdc build]# cmake --build . --parallel
In file included from /tmp/corrade/src/Corrade/Containers/Pointer.h:37,
from /tmp/corrade/src/Corrade/TestSuite/Tester.h:35,
from /tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:35:
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp: In member function ‘void Corrade::Utility::Test::{anonymous}::AssertDisabledTest::constexprTest()’:
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:136:37: in ‘constexpr’ expansion of ‘Corrade::Utility::Test::{anonymous}::divide(15, 0)’
/tmp/corrade/src/Corrade/Utility/Assert.h:242:6: error: call to non-‘constexpr’ function ‘Corrade::Utility::Test::{anonymous}::divide(int, int)::<lambda()>’
239 | static_cast<void>((condition) ? 0 : ([&]() { \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
240 | Corrade::Utility::Error{Corrade::Utility::Error::defaultOutput()} << message; \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
241 | std::abort(); \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
242 | }(), 0))
| ~^~
/tmp/corrade/src/Corrade/Utility/DebugAssert.h:86:5: note: in expansion of macro ‘CORRADE_CONSTEXPR_ASSERT’
86 | CORRADE_CONSTEXPR_ASSERT(condition, message)
| ^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:41:33: note: in expansion of macro ‘CORRADE_CONSTEXPR_DEBUG_ASSERT’
41 | #define TESTED_CONSTEXPR_ASSERT CORRADE_CONSTEXPR_DEBUG_ASSERT
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:123:12: note: in expansion of macro ‘TESTED_CONSTEXPR_ASSERT’
123 | return TESTED_CONSTEXPR_ASSERT(b, "b can't be zero"), a/(b + 5);
| ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Assert.h:239:42: note: ‘Corrade::Utility::Test::{anonymous}::divide(int, int)::<lambda()>’ is not usable as a ‘constexpr’ function because:
239 | static_cast<void>((condition) ? 0 : ([&]() { \
| ^
/tmp/corrade/src/Corrade/Utility/DebugAssert.h:86:5: note: in expansion of macro ‘CORRADE_CONSTEXPR_ASSERT’
86 | CORRADE_CONSTEXPR_ASSERT(condition, message)
| ^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:41:33: note: in expansion of macro ‘CORRADE_CONSTEXPR_DEBUG_ASSERT’
41 | #define TESTED_CONSTEXPR_ASSERT CORRADE_CONSTEXPR_DEBUG_ASSERT
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:123:12: note: in expansion of macro ‘TESTED_CONSTEXPR_ASSERT’
123 | return TESTED_CONSTEXPR_ASSERT(b, "b can't be zero"), a/(b + 5);
| ^~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Assert.h:239:42: note: lambdas are implicitly ‘constexpr’ only in C++17 and later
239 | static_cast<void>((condition) ? 0 : ([&]() { \
| ^
/tmp/corrade/src/Corrade/Utility/DebugAssert.h:86:5: note: in expansion of macro ‘CORRADE_CONSTEXPR_ASSERT’
86 | CORRADE_CONSTEXPR_ASSERT(condition, message)
| ^~~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:41:33: note: in expansion of macro ‘CORRADE_CONSTEXPR_DEBUG_ASSERT’
41 | #define TESTED_CONSTEXPR_ASSERT CORRADE_CONSTEXPR_DEBUG_ASSERT
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/corrade/src/Corrade/Utility/Test/AssertDisabledTest.cpp:123:12: note: in expansion of macro ‘TESTED_CONSTEXPR_ASSERT’
123 | return TESTED_CONSTEXPR_ASSERT(b, "b can't be zero"), a/(b + 5);
| ^~~~~~~~~~~~~~~~~~~~~~~
from corrade.
Related Issues (20)
- Error when installing via HunterGate HOT 7
- Prefix cmake options with CORRADE_ HOT 4
- Windows: inconsistent redefinition of _aligned_malloc HOT 3
- Corrade adds /wd*** warning disablements to "clang.exe" on windows. HOT 1
- Building Corrade with -std=c++20 causes errors inside MinGW <numbers> header HOT 3
- Corrade fails to compile with emscripten 3.1.22 HOT 4
- Opt-in to native UTF-8 support for OS interaction on Windows
- std::tuple_size / tuple_element specializations for Corrade containers HOT 1
- error: cannot initialize a variable of type 'const char *const' with an rvalue of type 'int' HOT 3
- Optimizing compilation time for the test suite -- an analysis HOT 3
- Interconnect - Slots are not called according to their record order HOT 1
- V8::Zone Allocator HOT 1
- NEON code does not build on armv7 HOT 2
- what to set CORRADE_INCLUDE_DIR to for in-source-builds HOT 2
- JsonToken::asObject() odd behavior with empty objects HOT 2
- New Release HOT 1
- Broken Interconnect on Clang-CL 16.0.5 HOT 9
- Packaging location of GDB script files HOT 8
- Container::Pointer does not work with forward declaration anymore HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from corrade.