https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93301

--- Comment #17 from Martin Uecker <muecker at gwdg dot de> ---
(In reply to Vincent Lefèvre from comment #16)
> (In reply to Martin Uecker from comment #15)
> > I do not think the C standard can be read in a way where reading a variable
> > can yield a different value each time (except if the access is UB). For
> > unspecified values it talks about "the value chosen in each instance" not
> > about "the value chosen for each read of a variable".
> 
> But any instance of what?

Instance of the unspecified value. 

Every time the standard says "a padding byte takes an unspecified value" 
or "the function returns an unspecified value" or something "stores an
unspecified value" a specific value is chosen. 

If it wanted to say that a read of an uninitialized variable yields an new
value each time it read, there would be a sentence in the paragraph about
lvalue conversion such as "an lvalue of an uninitialized object is converted to
an unspecified value". Then "each instance" would be new unspecified value
produced during each lvalue conversion. But it does not says this.

> There is no context in the definition (possibly
> except the operation that yields the value).

The operation that yields the value is the when the object is initialized (or
would be initialized if it had an initializer). This is in 6.2.4p6 where it
says "...; otherwise, the value becomes indeterminate each time the declaration
is reached."  An indeterminate value is either a trap representation or an
unspecified value. If the type does not have trap representations, then this is
the same as "...; otherwise, the value becomes and unspecified value each time
the declaration is reached". So the point in time where the value has to be
chosen is defined by the C standard.

Reply via email to