Mail Archives: djgpp/1997/09/04/07:51:16
Peter Berdeklis wrote:
>
> The original poster said that this code works correctly on other compilers
> _as written_, not with a little modification and not yielding undefined
> behaviour. That's why he had a complaint with gcc/DJGPP.
If it worked, it doesn't meant it isn't undefined behaviour.
> If printf prints the right answer as it is written above then there is
> probably a bug in the printf library function or the variable argument
> list passing mechanism of the compiler. As written printf should expect 2
> floating point numbers in the variable argument list that follows the
> format specifier.
How should the compiler know how to split a complex into 2 FPN's?
> The first argument printf is passed is a "complex" structure or class.
> Perhaps if the very first member of the structure is a float (i.e. the
> structure has no virtual functions, or gcc stores the virtual function
> pointer somewhere other than the beginning of the structure) then the
> first number will be printed out correctly by accident. Not the
> compiler's fault.
Are you looking for instances where undefinied behaviour yields the
expected result? If you want to get something done from the compiler, at
least what you can do is to respect it's rules. BTW float != double. And
since I don't know how complex is defined (and I don't need to)...
--
+----------------+
| Vik Heyndrickx |
+----------------+
- Raw text -