🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6095

Re: No warnings when passing complex to real functions

#6095
From: Andreas Schwab
Date: Wed, 27 Nov 1996 00:00
29 lines
1408 bytes
Wayne Hayes <wayne@cs.toronto.edu> writes:

|> This should fail with an error; or at the very least, print a warning:
|> $ cat foo.c
|> #include <stdio.h>
|> #include <math.h>

|> int main()
|> {
|> 	__complex__ z = 1.0i;

|> 	printf ("exp(%gi) = %g + %gi\n", __imag__ z,
|> 		__real__ exp(z), __imag__ exp(z));

|> 	return 0;
|> }
|> $ gcc -Wall foo.c -lm
|> $ ./a.out
|> exp(1i) = 1 + 0i

|> It appears that exp() (and sin()) just take the real part of it's argument,
|> ignoring the imaginary part.

Does <math.h> declare *prototypes* for exp() and sin()?  Without them gcc
cannot help you here.
-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"
Technical Details
Message-ID: <vyzohgjdeba.fsf@issan.informatik.uni-dortmund.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <96Nov26.155726edt.4175-23225@church.cs.toronto.edu>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,e8c0f6f13cf0bf4e
X-Google-Attributes: gid113d02,public
From: schwab@issan.informatik.uni-dortmund.de (Andreas Schwab)
Subject: Re: No warnings when passing complex to real functions
Date: 1996/11/27
Message-ID: <vyzohgjdeba.fsf@issan.informatik.uni-dortmund.de>
X-Deja-AN: 201009785
sender: schwab@issan.informatik.uni-dortmund.de
references: <96Nov26.155726edt.4175-23225@church.cs.toronto.edu>
organization: Dortmund University, Germany
x-gateway: relay6.UU.NET from bug-gcc to gnu.gcc.bug; Wed, 27 Nov 1996 05:26:57 EST
newsgroups: gnu.gcc.bug