3 ms·
This same blog has a post on the idiosyncrasies of the C preprocessor. Reminds me of several convoluted macros I assembled to stress test a C/C++ static analyze
by aarchi 6y ago
This same blog has a post on the idiosyncrasies of the C preprocessor. Reminds me of several convoluted macros I assembled to stress test a C/C++ static analyzer at my last job. My favorite that I wrote was the following, combining line continuations, trigraphs, digraphs, universal character names, and block comments. Particularly insidious is the line continuation between / and * in the block comment. It is equivalent to: #define 🇩🇪() "de"
??/
%: \
/??/
*/*\
**/\
def\
ine\
\U\
0??/
001\
F??/
1E9\
??/\
U00\
01F\
1EA\
(??/
) "\
de"\
This example also exposes undefined behavior from the C++ standard: "if a splice results in a character sequence that matches the syntax of a universal-character-name, the behavior is undefined" [0].
[0]: https://eel.is/c++draft/lex.phases#1.2 https://eel.is/c++draft/lex.phases#1.2