|
|
Subscribe / Log in / New account

Obsolete C for you and me

Obsolete C for you and me

Posted Dec 9, 2023 8:21 UTC (Sat) by pm215 (subscriber, #98099)
In reply to: Obsolete C for you and me by rrolls
Parent article: Modern C for Fedora (and the world)

Should gcc be able to compile sixth edition Unix code with its reversed increment operators ("x =+ 2;") and unnamed structs, or are we just debating at what point a particular version of C is obsolete enough that modern compilers need not support it?


to post comments

Obsolete C for you and me

Posted Dec 12, 2023 13:33 UTC (Tue) by rrolls (subscriber, #151126) [Link] (2 responses)

Well, of course I'd say "x =- 2;" should be parsed as "x = (-2);", not as "x -= 2;".

However:

Did any actual C standard parse it as the latter?

If yes, then my point stands, meaning that if someone invokes a C compiler and explicitly tells it to use whatever old C standard that was, then that's the way it should be parsed. Does this cause a security issue? No! Because you have explicitly specify that.

If no, then the point is moot, because if it's not specified behavior then I'd say the compiler is free to change its behavior as it pleases.

Obsolete C for you and me

Posted Dec 12, 2023 14:08 UTC (Tue) by farnz (subscriber, #17727) [Link]

This now comes down to the definition of "actual C standard". No ISO C standard parsed it as the latter, but some K&R versions did. However, K&R wasn't a formal standard - it was more or less defined in terms of what the K&R compiler did.

Obsolete C for you and me

Posted Dec 12, 2023 14:13 UTC (Tue) by excors (subscriber, #95769) [Link]

The =+ style operators are used in the undated C Reference Manual at https://www.bell-labs.com/usr/dmr/www/cman.pdf

According to https://www.bell-labs.com/usr/dmr/www/chist.html :

> B introduced generalized assignment operators, using x=+y to add y to x. The notation came from Algol 68 [Wijngaarden 75] via McIlroy, who had incorporated it into his version of TMG. (In B and early C, the operator was spelled =+ instead of += ; this mistake, repaired in 1976, was induced by a seductively easy way of handling the first form in B's lexical analyzer.)


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds