is there any word processing software for the pdp11?
Jon Elson
elson at pico-systems.com
Tue Dec 2 21:25:34 CST 2014
On 12/02/2014 01:03 PM, Roe Peterson wrote:
>> On Dec 2, 2014, at 11:08 AM, Jon Elson <elson at pico-systems.com> wrote:
>> still discovering new ways that
>> C code that looks perfectly correct can screw up horribly. Last one was
>> yesterday.
>>
>> Boiling it down, we had :
>>
>> long long int A;
>> int B;
>> A = B << 32;
>>
>> This means that some field of B gets shifted to the right by 32 bits, and
>> fit into the upper 32-bits of A.
>>
>> Now, any decent compiler should either extend B to the length of A, or
>> as the C rules specify, NOT extend B, and therefor ought to warn you
>> that it is losing significant bits. No warning, no extending the variable
>> before shifting the bits off the end of the word. So, A always gets
>> a zero! UGH! Stupid! I could almost write a book of these sorts
>> of gotchas.
> Hmm. What C compiler did this, on what distro? I'm pretty sure that this throws a compiler warning in gcc with -Wall...
>
>
Should have been gcc on a 64-bit Ubuntu 12.04 build, I
THINK. (Not absolutely sure what
machine they were running this on at work.) I have NO IDEA
what compiler flags were used,
however. It was buried deep in a several page Make file,
with those 5 line long compile
lines filled with switches and includes. It definitely did
NOT produce any warning at
all.
Jon
More information about the cctech
mailing list