In article , "Wilco Dijkstra" writes: |>
|> I'd certainly be interested in the document. My email is above, just make |> the obvious edit.
Sent.
|> > |> I bet that most code will compile and run without too much trouble. |> > |> C doesn't allow that much variation in targets. And the variation it |> > |> does allow (eg. one-complement) is not something sane CPU |> > |> designers would consider nowadays. |> >
|> > The mind boggles. Have you READ the C standard? |> |> More than that. I've implemented it. Have you?
Some of it, in an extremely hostile environment. However, that is a lot LESS than having written programs that get ported to radically different systems - especially ones that you haven't heard of when you wrote the code. And my code has been so ported, often without any changes needed.
|> It's only when you implement the standard you realise many of the issues are |> irrelevant in practice. Take sequence points for example. They are not even |> modelled by most compilers, so whatever ambiguities there are, they simply |> cannot become an issue.
They are relied on, heavily, by ALL compilers that do any serious optimisation. That is why I have seen many problems caused by them, and one reason why HPC people still prefer Fortran.
|> Similarly various standard pendantics are moaning |> about shifts not being portable, but they can never mention a compiler that |> fails to implement them as expected...
Shifts are portable if you code them according to the rules, and don't rely on unspecified behaviour. I have used compilers that treated signed right shifts as unsigned, as well as ones that used only the bottom 5/6/8 bits of the shift value, and ones that raised a 'signal' on left shift overflow. There are good reasons for all of the constraints.
No, I can't remember which, offhand, but they included the ones for the System/370 and Hitachi S-3600. But there were also some microprocessor ones - PA-RISC? Alpha?
|> Btw Do you happen to know the reasoning behind signed left shifts being |> undefined while right shifts are implementation defined.
Signed left shifts are undefined only if they overflow; that is undefined because anything can happen (including the CPU stopping). Signed right shifts are only implementation defined for negative values; that is because they might be implemented as unsigned shifts.
|> It will work as long as the compiler supports a 32-bit type - which it will of |> course. But in the infinitesimal chance it doesn't, why couldn't one |> emulate a 32-bit type, just like 32-bit systems emulate 64-bit types?
Because then you can't handle the 64-bit objects returned from the library or read in from files! Portable programs will handle whatever size of object the system supports, without change - 32-bit, 64-bit,
48-bit, 128-bit or whatever.
|> Actually various other languages support sized types and most software |> used them long before C99. In many cases it is essential for correctness |> (imagine writing 32 bits to a peripheral when it expects 16 bits etc). So |> you really have to come up with some extraordinary evidence to explain |> why you think sized types are fundamentally wrong.
Not at all. That applies ONLY to the actual external interface, and Terje and I have explained why C fixed-size types don't help.
Regards, Nick Maclaren.