Sorry if it's a stupid question, but I couldn't find much information. I just want to assign the result of a comparison in a variable, like this:
int a = 3, b = 2; // In actual code they're not integer literals
int result = a > b;
When compiling, gcc
(with -Wall
) doesn't complain, and looking at the assembly output I found it's translated to cmp
and setle
(or setg
etc.). I'm wondering whether it's invalid (C) code or considered bad practice, since I see it's never used.