From 1115949666765421661 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f78e5,e94695845965b249 X-Google-Attributes: gidf78e5,public X-Google-ArrivalTime: 1992-10-29 11:31:08 PST Newsgroups: comp.std.c++ Path: sparky!uunet!microsoft!hexnut!jimad From: jimad@microsoft.com (Jim Adcock) Subject: Re: Zero-length structures and pointer comparisons Message-ID: <1992Oct30.003946.10484@microsoft.com> Date: 30 Oct 92 00:39:46 GMT Organization: Microsoft Corporation References: <1992Oct21.153904.13965@ucc.su.OZ.AU> <1992Oct26.170404.1904@microsoft.com> <1992Oct28.184135.25475@ucc.su.OZ.AU> Lines: 62 In article <1992Oct28.184135.25475@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes: | I dont understand. For a start, there is NO requirement |that I can see that < is a partial order. Have I missed something? What you have missed is the implication of this statement. *No requirement* is equivalent to a *Permission* for compiler vendors and programmers to write compilers and programs making use of that *Permission.* Such compilers and programs are perfectly legal and valid C and C++ compilers/programs. They are *conforming* -- they're just not *strictly conforming* programs. | As I understand it the rules are: | | 1) pointers to the same object compare == | 2) within an array, < is a total order | 3) In other cases < is implementation defined. 4) Don't gratuitously change C++ from C so as to break existing legal C programs. |Any program relying on some implementation defined order (3) cannot |be portable. *It doesn't have to be portable to be legal!* It is quite legitimate to write legal programs that aren't portable -- in fact obviously 99.9% of the interesting C/C++ programs *aren't* strictly portable! "Portability" then is the wrong measure when it comes to standards. Instead, the issue is legality. You cannot gratuitously take a large class of programs and make them all illegal. Such destroys the compatibility that C++ is justly famous for. |If a total ordering was required, programs utilising |this requirement would be portable. Nope. They would only become portable if this was the last non-portability in that program -- hardly likely. On the converse side, tons of previously legal but not *strictly* portable programs would now become illegal. Thus your trade-off would represent a major lose: Lots of legal programs become busted in exchange for making an unlikely few programs portable. |Surely very few implementation |defined orderings would not be total orders anyhow, so very few |existing programs would be broken if the rules changed? Segment hacks in programs for x86 systems are EXTREMELY common. If you were to require a total ordering on pointers a HUGE amount of currently conforming C/C++ programs would suddenly become illegal. This is clearly not acceptable, and not well thought out. My off-the-top-of-my-head estimate for the number of C++ programmers that would fall in this category would be several hundred thousand. [Based on C++ compiler sales numbers] The number of C programmers affected would probably be even larger -- unless you expect C/C++ compilers to implement total ordering on C++ programs but partial orderings on C programs? Wrong. Besides, total ordering would require non-flat model programs to become bigger and slower. But you guys already know that. Now how about cutting out the game playing -- this issue has already been fought out in the ANSI C committees. Why reopen old ground?