Error in AIDGE_ASSERT macro due to unescaped braces in assertion conditions
Required prerequisites
-
Make sure you've read the documentation. Your issue may be addressed there. -
Search the issue tracker and discussions to verify that this hasn't already been reported. +1 or comment there if it has.
What commit version of aidge do you use
-
aidge_core
: dev
Problem description
When the assertion on line 238 of Tensor.cpp is false, an error occur :
error: cannot switch from manual to automatic indexing
This issue arises because the assertion condition string, when converted to a string literal, contains braces "{0}" (automatic indexing) that conflict with the formatting placeholders "{}" (manual indexing) used by the fmt
library in logging functions.
Reproducible code :
#include <catch2/catch_test_macros.hpp>
#include "aidge/utils/ErrorHandling.hpp"
namespace Aidge
{
TEST_CASE("Assertion formatting error", "[Assert]")
{
AIDGE_ASSERT(false && "{0}", "foo");
}
}
Run with :
cmake --build build -j8 && ./build/unit_tests/tests_aidge_core "[Assert]"
Output :
Filters: [Assert]
Randomness seeded to: 1154735448
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tests_aidge_core is a Catch2 v3.0.1 host application.
Run with -? for options
-------------------------------------------------------------------------------
Assertion formatting error
-------------------------------------------------------------------------------
/nobackup/Perso/aidge/aidge/aidge_core/unit_tests/data/Test_bug.cpp:6
...............................................................................
/nobackup/Perso/aidge/aidge/aidge_core/unit_tests/data/Test_bug.cpp:6: FAILED:
due to unexpected exception with message:
cannot switch from manual to automatic argument indexing
===============================================================================
test cases: 1 | 1 failed
assertions: 1 | 1 failed
From what I've seen, it is the only place in aidge where we have an assertion with "{[0-9]}".
I checked with the following regex : 'AIDGE_ASSERT\([^;]*?\{[0-9]+'
Edited by Jerome Hue