Soon after learning the C language in the late 80s, before an ANSI C compiler was available on the machines I was using, it occurred to me to check if the following compiles
int a, b, c;
foo() {
(a == 0 ? b : c) = 1;
}
and it did! The compiler has propagated the Lvalue property of the last two operands of the ternary expression to the expression itself. For a while, I amused people by demonstrating them that "Easter egg" in the compiler.
Now, of course, according to the ANSI C standard, we have to write *(a == 0 ? &b : &c)
.
However, I cannot remember or figure out which compiler it was. The original K&R compiler I tried on an online PDP-11 simulator says "3: Lvalue required", as well as a compiler used in BSD 2.9 (PCC-based, I guess?).
It could have been a compiler on MS-DOS, but I remember that at least one compiler on a UNIX platform also allowed that.
I'm not trying to find out exactly which one it was in my case, or which one was the earliest; an example of a pre-ANSI C compiler written in the 70-80s for any commercially-available platform/OS which existed at the time and which compiles the above test case would be enough.
Googling "lvalue ternary expression" yields discussions about the fact that a ternary expression can be an Lvalue in C++ but not in the contemporary C.