I have tried placing C++20
's [[likely]]
and [[unlikely]]
attributes at various locations around the condition of a do
-while
loop, and it seems placing them at the end of the line after the semicolon is accepted by all three major compilers:
int main(int i, char**)
{
do {
++i;
} while (i < 42); [[likely]]
return i;
}
However this looks rather strange. Is this really the correct place for the attribute?