4 ms·
> the K&R example is an example of explicitly undefined behavior in the C standard You can’t blame K&R C for that. It predates “the C standard” by over a decad
by Someone 2y ago
> the K&R example is an example of explicitly undefined behavior in the C standard
You can’t blame K&R C for that. It predates “the C standard” by over a decade (1978 vs 1989)
When it was written, what K&R said was C.
- layer8 2y agoThe example is still the same in the second edition of K&R, which is based on C89.
- trealira 2y agoThe second edition was released in 1988, and it was based on a draft of the first ANSI C standard, and even then, the line stating that this was undefined behavior was already present. http://jfxpt.com/library/c89-draft.html#A.6.2 http://jfxpt.com/library/c89-draft.html#A.6.2 > A pointer to a function is converted to point to a function of a different type and used to call a function of a type not compatible with the original type (3.3.4).