Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!uupsi!sunic!isgate!krafla!pierre From: pierre@rhi.hi.is (Kjartan Pierre Emilsson) Newsgroups: comp.lang.c Subject: Re: Nasty bug Message-ID: <2117@krafla.rhi.hi.is> Date: 30 Aug 90 08:52:35 GMT References: <0093BF08.7F3834E0@rigel.efd.lth.se> Organization: University of Iceland Lines: 35 From article <0093BF08.7F3834E0@rigel.efd.lth.se>, by e89hse@rigel.efd.lth.se: > Hi ! > > I had a lot of trouble with a bug yesterday. The code was similar to the > following: > > [Code deleted] > prnval(s,f) > char *s; > float f; > > And it didn't work. Why? The answer is that the parameter f is a > double, not a float since all floats are converted to double when they are > passed as arguments to functions.Therefore &f is a ptr to double rather than > a float. > > Henrik Sandell I don't know what other think, but as a relatively experienced C programmer, I find this bug very counter-intuitive, being used to think that when I declare some variable in code to be of a given type, I certainly want it to be of that given type, regardless of what crap I choose to put in it later. From that point of view, float variables should not be allowed in function argument declaration. Personally I never use floats, but this is certainly a *very* nasty bug. -Kjartan ------------------------------------------------------------------------- Kjartan Pierre Emilsson Science Institute of the University of Iceland Dunhaga 3 Reykjavik ICELAND e-mail: pierre@krafla.rhi.hi.is