fjhenigman@watcgl.waterloo.edu (Frank J. Henigman) (05/02/90)
The following program prints zero but it should print 1.
If you modify the program so that foo() does not return a struct it works
as expected.
struct crud { long x; } w;
struct crud foo( float f, long k )
{
printf( "%ld\n", k );
return w;
}
main()
{
foo( 0.0, 1L );
}
--
fjhenigman@watcgl.uwaterloo.ca Computer Graphics Lab
fjhenigman@watcgl.waterloo.edu Frank J. Henigman University of Waterloo
...!watmath!watcgl!fjhenigman Waterloo, Ontario, Canadalmo@lsr-vax.UUCP ("Lance M. Optican - LMO") (05/07/90)
There is a bug in the Irix C-compiler:
----- Begin Included Message -----
Date: 2 May 90 16:47:35 GMT
From: "Frank J. Henigman" <uunet!ucbvax.berkeley.edu!att!watmath!watserv1!watcgl!fjhenigman>
Organization: Computer Graphics Laboratory, University of Waterloo, Ontario, Canada
Subject: 3.2 C compiler bug
Message-Id: <1990May2.164735.27436@watcgl.waterloo.edu>
Sender: uunet!BRL.MIL!info-iris-request
To: info-iris@BRL.MIL
Status: RO
The following program prints zero but it should print 1.
If you modify the program so that foo() does not return a struct it works
as expected.
struct crud { long x; } w;
struct crud foo( float f, long k )
{
printf( "%ld\n", k );
return w;
}
main()
{
foo( 0.0, 1L );
}
--
fjhenigman@watcgl.uwaterloo.ca Computer Graphics Lab
fjhenigman@watcgl.waterloo.edu Frank J. Henigman University of Waterloo
...!watmath!watcgl!fjhenigman Waterloo, Ontario, Canada
----- End Included Message -----
This seems to be a problem with the function prototyping. If you
change to the old-fashioned 'C' convention, the problem goes away:
struct crud { long x; } w;
struct crud foo(f, k )
float f;
long k;
{
printf( "%ld\n", k );
return w;
}
main()
{
foo( 0.0, 1L );
}
Good Luck,
Lance M. Optican
Laboratory of Sensorimotor Research
National Eye Institutedavea@quasar.wpd.sgi.com (David B. Anderson) (05/10/90)
In article <9005071321.AA27323@> lmo@lsr-vax.UUCP ("Lance M. Optican - LMO") writes: >There is a bug in the Irix C-compiler: [ ] >The following program prints zero but it should print 1. >If you modify the program so that foo() does not return a struct it works >as expected. [ ] >This seems to be a problem with the function prototyping. If you >change to the old-fashioned 'C' convention, the problem goes away: Thanks for the report. The bug has been fixed for the release after 3.2. Regards, [ David B. Anderson Silicon Graphics (415)335-1548 davea@sgi.com ] [``What can go wrong?'' --Calvin and Hobbes]