[Cryptography] GCC bug 30475 (was Re: bounded pointers in C)
Bill Frantz
frantz at pwpconsult.com
Thu May 1 16:08:05 EDT 2014
On 5/1/14 at 9:38 AM, leichter at lrw.com (Jerry Leichter) wrote:
>The compiler always knows the target architecture. But that
>result of an expression like x > x + 1 is undefined if x + 1
>overflows. Again, it might trap.
I'm sorry, but I don't have much time, and am about to go away
from the Internet for a while, so I won't give you response the
careful thought it deserves (and probably not see your responses
for several weeks).
While compilers don't always know the target architecture, the
optimizer phase in some implementations may not. I have seen
compilers that produced a intermediate language which is then
translated to machine code.
From the view of safe programming, if x > x+1 traps and aborts
the program, this is usually better than throwing out the
statement entirely. In the very common case of twos compliment
modular arithmetic the statement has meaning and should be executed.
While I certainly don't know all architectures and compilers,
every one I know permits arithmetic overflow traps to be masked
so they don't occur and the result of the operation is modulo
the arithmetic base of the machine. Both the IBM 650 and the
1620 behaved this way with their decimal arithmetic. The 1620
was variable word length so the modulus depended on the word length.
But what I think I really want is a safe mode where dangerous
optimizations are avoided or terminal compile errors are
generated. I hate thinking that the only safe low level language
is assembler.
[I have heard mention of optimizing assemblers which will remove
code, but never encountered one. The only optimizing assembler I
know is the IBM 650 SOAP assembler which arranged instruction
and data words around the rotating drum main memory to minimize
access time.]
Cheers - Bill
---------------------------------------------------------------------------
Bill Frantz |"We used to quip that "password" is the most common
408-356-8506 | password. Now it's 'password1.' Who said
users haven't
www.pwpconsult.com | learned anything about security?" -- Bruce Schneier
More information about the cryptography
mailing list