Re: Miscompilation of remainder expressions

2007-01-18 Thread Morten Welinder
For sure a/b is undefined In C, it is. In assembler it is perfectly well defined, i.e., it traps. But how is the trap handler supposed to know the source of a given instruction? M.

Re: Relying on precise integer calculation with double

2006-04-07 Thread Morten Welinder
gcc really, really ought to specify more precisely what floating point semantics one can depend on. Bug 323, paraphrased, says "floating point comparisons return random numbers". Ok, that's pumping it a bit, but consider the following qsort comparison function right out of K&R 2nd Edition page 1

Re: funny problem with g++

2005-12-07 Thread Morten Welinder
>> This is a joke, you are kidding, right ? > No, we're not kidding. RTFM: Section, 5.12 Arrays of Length Zero He is kind of right, though. Outside struct (or perhaps union), zero-sized arrays make little sense and could be rejected. Or else I am missing something too. M.

Re: Pointers in comparison expressions

2005-07-13 Thread Morten Welinder
> Relational tests between pointers is only allowed by > the ISO C standard if the two pointers point into the > same array, or if a pointer points to exactly one byte > beyond the array. There actually is a way to compare arbitrary data pointers within the C standards: you send the pointers throu

Re: signed is undefined and has been since 1992 (in GCC)

2005-06-28 Thread Morten Welinder
> In particular, a very large number of C and C++ programs are written > with the assumptions: >- signed and unsigned types are modulo, except in loop induction > variables where it's bad taste Well, as demonstrated by INT_MIN/-1, gcc has NEVER fulfilled such assumptions on i86 and, quite likely,

Re: Do C++ signed types have modulo semantics?

2005-06-27 Thread Morten Welinder
| signed types are undefined on overflow. [5/5] and [3.9.1/2,3] > But a compiler could define them to be modulo -- that is the whole > point. The paragraph does not say they don't "modulo". True, but you are going to have to deal with the run-time version of (int)0x8000 / -1 which is u

Re: Sine and Cosine Accuracy

2005-05-26 Thread Morten Welinder
> But, you are using a number in the range of 2^90, only > have 64 bits for storing the floating point representation, and > some of that is needed for the exponent. > 2^90 would require 91 bits for the base alone (as an integer > value), plus a couple more for the '*PI' portion, and then > more fo

Re: Sine and Cosine Accuracy

2005-05-26 Thread Morten Welinder
> Yes, but within the defined mathematical ranges for sine and cosine -- > [0, 2 * PI) -- the processor intrinsics are quite accurate. If you were to look up a serious math book like Abramowitz&Stegun1965 you would see a definition like sin z = ((exp(iz)-exp(-iz))/2i [4.3.1]