Earlier quoted context omitted.
> And implementing it with a for loop also leaks. Assuming you're talking about this for loop: for (int i = 0; i then no, it doesn't leak, because the result of the resulting conditional branch doesn't depend on a secret. The only reason NaCl unrolls that loop is because neeed moar speeed . If you were talking about the early return straightforward for loop: for (int i = 0; i Then yeah, it leaks. > Longer term worry…
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.
Maintainers of crypto libraries inspect the assembly when upgrading their compilers, test with many compilers and document the versions of compilers they support.