🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Jason Merrill Thu, 21 Jan 1993 23:06
Prototype handling bug(?) in 2.3.3
#1631
Author: Jason Merrill
Date: Thu, 21 Jan 1993 23:06
27 lines
1418 bytes
When compiling ckufio.c from the C-Kermit 5A(188) distribution, I get this
error:

ckufio.c:390: conflicting types for `getpwuid'
ckufio.c:390: An argument type that has a default promotion
ckufio.c:390: can't match an empty parameter name list declaration.
/usr/include/pwd.h:27: previous declaration of `getpwuid'

A condensation of the file being compiled would be:

-----
typedef unsigned short uid_t;

struct passwd* getpwuid();
struct passwd* getpwuid(uid_t);
-----

And indeed that fragment reproduces the bug (misfeature)?  I was under the
impression that you could pass anything you darn well pleased through ().
I suppose the error means that the compiler would have to convert the
argument being passed to unsigned short before passing it, but this machine
is little-endian, so passing an int straight through wouldn't hurt.

Perhaps this is proper behavior; what do you think?

--
Jason Merrill					jason@jarthur.claremont.edu
Re: Prototype handling bug(?) in 2.3.3
#1651
Author: Jason Merrill
Date: Tue, 26 Jan 1993 01:44
58 lines
2063 bytes
>>>>> 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads