Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!sun-barr!newstop!sun!amdcad!nucleus!tim From: tim@nucleus.amd.com (Tim Olson) Newsgroups: comp.os.minix Subject: Re: float VS double: The return... Message-ID: <29812@amdcad.AMD.COM> Date: 10 Apr 90 18:10:35 GMT References: <16383@nigel.udel.EDU> Sender: news@amdcad.AMD.COM Reply-To: tim@amd.com (Tim Olson) Organization: Advanced Micro Devices, Inc., Austin, Texas Lines: 50 Summary: Expires: Sender: Followup-To: In article <16383@nigel.udel.EDU> ARCHER@segin4.segin.fr writes: | I don't think for my compiler :-), but a compiles as a double (sizeof being 8), | and *a in test1 has nothing near the same value as a in test: | | test(a) float a; | { | a = 0.1; | printf("%f\n", a); | test1(&a); | } | | test1(a) float *a; | { | printf("%f\n", *a; | } | | said: | | 0.1 | 1.45000 | | | It seems that most compilers do the same kind of thing. So if your compiler | enables the user to do some mistakes, you'll lose portability: The program will | work compiled with C68, and not with any other compiler. What's more important? If you want to start progressing towards ANSI compatibility, then this must be fixed. The Standard says (in the Rationale Section): Some current implementations rewrite the type of a (for instance) |char| parameter as if it were declared |int|, since the argument is known to be passed as an |int| (in the absence of prototypes). The Standard requires, however, that the received argument be converted "as if" by assignment upon function entry. Type rewriting is thus no longer permissible. This means that in: f(c, f) char c; float f; { . . sizeof c should be 1 and sizeof f should be equal to sizeof(float). -- Tim Olson Advanced Micro Devices (tim@amd.com)