-
-
Notifications
You must be signed in to change notification settings - Fork 462
Debug assert #1175
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
Debug assert #1175
Changes from 2 commits
4f2c6ac
6fa4fad
1ba8480
cab3bda
eba6eda
6a1f790
e0e6bde
e02a685
97b3ed4
80f4814
07dfe30
d6adf29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,9 @@ namespace | |
{ | ||
CHECK_EQUAL(data[i], compare_data[i]); | ||
} | ||
|
||
//ETL_DEBUG and ETL_THROW_EXCEPTIONS are defined | ||
CHECK_THROW({ int d = data[data.size()]; (void)d; }, etl::array_out_of_range); | ||
} | ||
Comment on lines
+138
to
140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gate the out-of-bounds [] checks behind the same flags used by ETL_DEBUG_ASSERT. Unconditionally requiring a throw will fail in release or non-exception builds. Guard the checks so they only run when ETL_IS_DEBUG_BUILD && ETL_USING_EXCEPTIONS (or ETL_DEBUG_USING_EXCEPTIONS if adopted). - //ETL_DEBUG and ETL_THROW_EXCEPTIONS are defined
- CHECK_THROW({ int d = data[data.size()]; (void)d; }, etl::array_out_of_range);
+ // Only active when debug + exceptions route is enabled for ETL_DEBUG_ASSERT
+#if ETL_IS_DEBUG_BUILD && ETL_USING_EXCEPTIONS
+ CHECK_THROW({ int d = data[data.size()]; (void)d; }, etl::array_out_of_range);
+#endif 🤖 Prompt for AI Agents
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this applies because there are many tests that that rely on exceptions and debug build already. Basically most tests already rely on these build options. |
||
|
||
//************************************************************************* | ||
|
@@ -145,6 +148,9 @@ namespace | |
{ | ||
CHECK_EQUAL(data[i], compare_data[i]); | ||
} | ||
|
||
//ETL_DEBUG and ETL_THROW_EXCEPTIONS are defined | ||
CHECK_THROW({ int d = data[data.size()]; (void)d; }, etl::array_out_of_range); | ||
} | ||
|
||
//************************************************************************* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be other macros that make
ETL_DEBUG_ASSERT
consistent with the options provided by theETL_ASSERT_XXX
set.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filled out the rest of the asserts from the
ETL_ASSERT_XXX
set. I'm not sure if its useful or not but I also included macros forETL_DEBUG_USE_ASSERT_FUNCTION
andETL_DEBUG_LOG_ERRORS
.