https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116945
--- Comment #14 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > Thanks for the reference. But this does seem to be a bit of a circular > definition. It says the 'Valid attribute can be used to check whether the > value has a valid representation, and an invalid representation can be > created by an uninitialized object. But it doesn't define how it checks for > the invalid representation. It does state that it is not an error to check > the validity of an object that is invalid. > > "Determining whether X is normal and has a valid representation as part of > the evaluation of X'Valid is not considered to include an evaluation of X." This is a language standard, so it is defined in terms of external effects and doesn't delve into the implementation details, see for example: http://www.ada-auth.org/standards/22rm/html/RM-1-1-3.html "Evaluation" has a precise meaning in the standard (see 1.3.4(5/5) and 3.1(11)) and the above sentence only means that X'Valid does not count as an evaluation of X in this sense, nothing more. > But it looks like valgrind here determines that an evaluation of X is > happening because the code flow depends on uninitialized value. I can only repeat my comment #7: "Testing 'Valid means comparing the value with the allowed range, so how can you do that without accessing that value?"