问题 Why is this code giving error while compiling? My knowledge (and also this) of " if constexpr " says the else block shouldn't get compiled. if constexpr (true) { int a = 10; } else { int b = 10 } The error is: error: expected ‘,’ or ‘;’ before ‘}’ token Compiler used: g++ version 7.5.0 While compiling I used -std=c++17 flag. P.S. The missing ';' is intentional, just to check whether else is being compiled or not. 回答1: There are 2 separate, but related issues here. Firstly, if constexpr will