Compiler bug

Hans Albertsson hans at log-hb.UUCP
Thu May 9 23:53:22 AEST 1985


In article <1136 at sjuvax.UUCP> jss at sjuvax.UUCP (J. Shapiro) writes:
>I recently noticed that the following will not compile correctly on a
>4.2 BSD system:
>
>extern int usr1(), usr2(), usr3();
>
>int	usrprocs[] = { usr1, usr2, usr3 }
>
>whereas it compiles correctly on intel machines, cromix, and Aztec C.
>It seems to me that this is something the linker should be able to handle
>correctly, and therefore should not be a bug.
>
>Comments?
>
>Would someone be good enough to check this out on a sysV machine?
>
>Jon


I don't think your declaration is quite correct; Shouldnt it have been

int (usrprocs[])() = { usr1, usr2, usr3 } ?

This declares an array of functions returning integer, which is what
the objects usrn might be considered to be, while your declaration says
array of integer.

Not even my version is quite correct. I ususally say

int ( *usrprocs[] )() = { usr1 ... 

to get the proper effect, since ( to quote K&R ) " if a function name 
appears in an expression, not in the position of a function call,
a pointer to the function is generated."
-- 
Hans Albertsson, USENET/uucp: {decvax,philabs}!mcvax!enea!log-hb!hans
Real World:  TeleLOGIC AB, Box 1001, S-14901 Nynashamn,SWEDEN



More information about the Comp.unix mailing list