pete said:
Does that etc. lead to two different terms
whic distinguish 5.0f from 5.0 ?
Hmm, since the standard refers to any numerical floating point
constant as, ...err... "floating constant", one could use the
following:
single precision floating constant ( 5.0f )
double precision floating constant ( 5.0 )
long double precision floating constant ( 5.0l )
Still, only when being pedantic, of course...
And somehow I still do.
N869
6.3.2.1 Lvalues and function designators
[#1] An lvalue is an expression with an object type or an
incomplete type other than void; if an lvalue does not
designate an object when it is evaluated, the behavior is
undefined.
Therefore, the evaluation of any integer constant,
- when used as an lvalue -
The standard says what an lvalue is. Agreed.
and what happens when it is evaluted. Agreed.
The standard doesn't say anything about usage
affecting what happens when an lvalue is evaluated.
I happen to disagree, see below.
I agree with your advice, but the standard doesn't say that.
Huh?!? But in 6.3.2.1 the standard /explicitly/ states that
evaluating lvalues that do not designate objects (integer
constants being one example) invokes UB, which is Standardese
for: "Don't do it!"
That however does not affect the behaviour when evaluating the
same expression in a (r)value context [1], which is of course
well defined elsewhere in the standard.
6.3.2.1 defines which "thingies" qualify as candidates for valid
lvalues, not that these "thingies" are always lvalues. Otherwise
the paragraph would start like: "Expressions with object type
(...) are lvalues (...)" - which in turn would lead to the wrong
conclusion that evaluating an integer constant would invoke
undefined behaviour under all circumstances. - Since it doesn't,
it doesn't...
"Thingies" like 5 aren't lvalues in and of itself. They may
appear in lvalue (object) context, but in this case won't do
any good, as we happen to agree.
Consider:
int i;
int p;
int a[5], b[5];
i = 5; /* fine; i is a valid lvalue and 5 a valid rvalue */
ip = &5; /* invalid; 5 is an lvalue here, but you cannot compute
its address: it's an lvalue that doesn't designate
an object and is therefore unsuitable as an operand
to the unary & operator. [2] */
5 = 6; /* invalid; 5 is an lvalue that doesn't designate
an object and is therefore unsuitable as left
operand of an assignment operator [3], whereas 6 is
a valid rvalue. */
ip = &i; /* fine; ip and i are suitable lvalues */
a = b; /* invalid; a is an lvalue designating an object,
but it is not modifiable [3] */
[1] As opposed to object (lvalue) context.
[2] See C99 6.5.3.2#1
<OT> gcc emits "error: invalid lvalue in unary '&'" </OT>
[3] See C99 6.5.16
<OT> gcc emits "error: invalid lvalue in assignment" </OT>
Regards