8000 Merge pull request #755 from alrvid/main · arduino/ArduinoCore-mbed@1a7859c · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1a7859c

Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
#include <mstd_type_traits>
2727
#include <mstd_functional>
2828

29+
#pragma GCC push_options
30+
// This prevents the GCC compiler from applying optimizations that assume the code follows strict aliasing rules.
31+
// In order to prevent bugs arising from undefined behavior that is tricky to find in the Callback implementation,
32+
// or simply from compiler bugs in GCC.
33+
#pragma GCC optimize("-fno-strict-aliasing")
34+
// This prevents the GCC compiler from generating incorrect inline code for the Callback constructor.
35+
#pragma GCC optimize("-fno-inline")
36+
2937
// Controlling switches from config:
3038
// MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL - support storing non-trivial function objects
3139
// MBED_CONF_PLATFORM_CALLBACK_COMPARABLE - support memcmp comparing stored objects (requires zero padding)
@@ -36,7 +44,6 @@
3644
#define MBED_CONF_PLATFORM_CALLBACK_NONTRIVIAL 1
3745
#endif
3846

39-
4047
namespace mbed {
4148
/** \addtogroup platform-public-api */
4249
/** @{*/
@@ -835,4 +842,6 @@ Callback(R(*func)(const volatile T *, ArgTs...), const volatile U *arg) -> Callb
835842

836843
} // namespace mbed
837844

845+
#pragma GCC pop_options
846+
838847
#endif