delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/04/07:51:16

From: Vik Heyndrickx <Vik DOT Heyndrickx AT rug DOT ac DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: complex numbers, correct ??
Date: Mon, 01 Sep 1997 12:58:31 +0200
Organization: University of Ghent, Belgium
Lines: 32
Message-ID: <340A9FD7.456@rug.ac.be>
References: <5tsl8i$ce$1 AT news DOT IAEhv DOT nl> <Pine DOT SGI DOT 3 DOT 91 DOT 970827160403 DOT 12574A-100000 AT atmosp DOT physics DOT utoronto DOT ca> <3406B175 DOT 35AB AT rug DOT ac DOT be> <Pine DOT SGI DOT 3 DOT 91 DOT 970829111941 DOT 7949B-100000 AT atmosp DOT physics DOT utoronto DOT ca>
NNTP-Posting-Host: eduserv1.rug.ac.be
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019