2 ms·
Problem is the optimizer is totally free to implement the 'safe' code snippet using an 'unsafe' early return. According to the standard that would be completely
by Gibbon1 10y ago
Problem is the optimizer is totally free to implement the 'safe' code snippet using an 'unsafe' early return. According to the standard that would be completely legal.
- loup-vaillant 10y agoCorrect. It can. I was just explaining why I think it won't anyway.
- wolf550e 10y agoA compiler that did this optimization would immediately introduce a pragma guaranteed to result in constant time memcmp from some blessed source pattern. Maintainers of crypto libraries inspect the assembly when upgrading their compilers, test with many compilers and document the versions of compilers they support.