3 ms·
Tbf, C and C++ did constant folding for function calls since forever too (as well as pretty much any compiled language AFAIK), just not as a language feature, b
by flohofwoe 2y ago
Tbf, C and C++ did constant folding for function calls since forever too (as well as pretty much any compiled language AFAIK), just not as a language feature, but as an optimizer feature:
https://www.godbolt.org/z/Kja5jrWo5 https://www.godbolt.org/z/Kja5jrWo5
>I don't understand why it is so complex in C++
Because C++ is a completely overengineered boondoggle of a language where every little change destabilizes the Jenga tower that C++ had built on top of C even more ;)
- mlvljr 2y ago[dead]
- WalterBright 2y agoI'm not seeing it: int sum(int a, int b) { return a + b; } _Static_assert(sum(1,2) == 3, "message"); gcc -c -O x.c x.c:2:17: error: expression in static assertion is not constant _Static_assert(sum(1,2) == 3, "message");