On 1/1/2010 4:52 PM, Kaz Kylheku wrote:
> On 2010-01-01, Eric Sosman<> wrote:
>> [...]
>> Original K&R C had no unary + operator at all; it was added
>> in the 1989 ANSI Standard. It seems your compiler is in a sort
>> of half-way position: It obviously recognizes unary + in some
>> contexts, but not in others.
>
> So if a compiler refuses
>
> int g[ 1 ? 2 : 3 ]; /* invalid constant expression */
>
> it's in a halfway position with regard to supporting the ternary
> operator?
<Shrug.> Sure, why not? But it's hard to see how that
compiler could claim "C-ness" under any widespread definition,
since the ternary operator has been part of the language since
before the publication of K&R in 1978. (Still, people will
hang the label "C" on practically any compiler that accepts
semicolons. I once encountered a compiler for a "C" without
structs, unions, floating-point, and multidimensional arrays!)
The weird thing about the O.P.'s situation is that his
compiler clearly recognizes unary + as an operator (hence, it's
post-K&R), but somehow doesn't understand that +constant is a
constant expression (as any ANSI-and-beyond compiler must).
His compiler seems to be post-K&R but pre-ANSI; that's what I
meant by "half-way."
(There's also the possibility that the compiler is supposed
to be ANSI- or even post-ANSI-conforming, but has a bug. One of
the very first lessons I was taught was "The bug's in your code,
not in the compiler," but early lessons sometimes oversimplify.)
--
Eric Sosman
lid