home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!jarthur.claremont.edu!jason
- From: jason@jarthur.claremont.edu (Jason Merrill)
- Newsgroups: gnu.gcc.bug
- Subject: Re: Prototype handling bug(?) in 2.3.3
- Date: 25 Jan 1993 20:44:23 -0500
- Organization: GNUs Not Usenet
- Lines: 61
- Sender: daemon@cis.ohio-state.edu
- Approved: bug-gcc@prep.ai.mit.edu
- Distribution: gnu
- Message-ID: <9301241911.AA19972@life.ai.mit.edu>
- References: <JASON.93Jan21002234@it.claremont.edu>
-
- >>>>> bof@midget.saar.de (Patrick Schaaf) writes:
-
- > In gnu.gcc.bug you write:
- >>And indeed that fragment reproduces the bug (misfeature)? I was under the
- >>impression that you could pass anything you darn well pleased through ().
-
- > No, you can't. Assume the following code:
-
- > short a, b;
-
- > void foobar();
-
- > foobar(a,b); /*1*/
-
- > void foobar(short bla, short fasel);
-
- > foobar(a,b); /*2*/
-
- > In the first call to foobar, the shorts will be promoted to int by the
- > default promotion rules (the same way floats are converted to doubles),
- > thus (on a machine with 2 byte shorts and 4 byte ints) 8 bytes are passed
- > to foobar.
- > The second call, with the prototype in scope, will not apply default
- > promotion rules, and thus passes only the 4 bytes for the 2 shorts.
-
- Suppose you have
-
- void foobar();
-
- ....
-
- short a, b;
-
- foobar(a,b);
-
-
- void foobar(c,d)
- short c,d;
- {
- ...
- }
-
- Then are c and d promoted to int as well? Just curious.
-
-
- > You can't write function foobar to correctly accept both types of call.
- > IMHO, the compiler is a good one if it warns you about this possible pitfall.
-
- I would agree with that. Unfortunately, the compiler message is an error,
- not a warning, so I am forced to comment out the first prototype somehow.
- Unfortunately, it is in one of the system headers, which makes that an
- annoying task.
-
- Hmm...I just looked at the getpwuid man page, and evidently it takes an int
- parameter. I guess the compiler does know best...but I still think it
- should be a warning, not an error.
-
- Jason
-
-
-
-