Re:Maximal Min() and Max()
by spc476 on Thursday August 08, 2024 @09:44PM
(#41198125)
At this point, C and C++ are not compatible. Please stop with this "Oh, just compile C with a C++ compiler." That ship has sailed over twenty years ago with C99. One major difference is designated initializers, which works differently between C and C++ [1]. And C also allows structure literals in function calls:
[1] C++ requires the fields to be initialized in order; C doesn't have this restriction.
[ Parent
| on HN ]
Compound literals are especially pernicious[1] because GCC and (I think) clang support them in C++ mode, but they have expression lifetime like C++ temporary objects, not block lifetime as in C. That's a guaranteed recipe for dangling pointers and stack smashing/snooping.
[1] From a C++ is just a C superset perspective. In C compound literals are awesome.