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.
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
>> 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.
> 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
> 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,
| 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
> 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
> 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]