A cursed feature of C in 1972: Labels and functions were reassignable (i.e., lvalues)!
Uncategorized
22
Posts
12
Posters
15
Views
-
This snippet deliberately triggers a "Bus error -- Core dumped":
int o1[];
o1 = -3;
*o1;From Dennis_Tapes/dmr/cgd/cg1.c:expr.
@thalia Very interesting program too
did it ever up in anything later or was it more like an experiment? -
A cursed feature of C in 1972: Labels and functions were reassignable (i.e., lvalues)!
For example, this is a clever way to initialize once:
goto init;
init:
ouptr = oubuf;
init = init1;
init1:which is compiled to:
jmp *4120
mov 4136,4144
mov 4122,4120Note the indirect jump and assignment to that address. All gotos used indirect jumps. This apparently would have also worked with functions.
-
R relay@relay.mycrowd.ca shared this topic