From S.R.Kilvington- at -soton.ac.uk Mon Oct 30 08:45:50 1995 Received: from beech.soton.ac.uk for S.R.Kilvington%!at!%soton.ac.uk by www.ccl.net (8.6.10/950822.1) id IAA09935; Mon, 30 Oct 1995 08:41:57 -0500 Received: from willow.soton.ac.uk (willow.soton.ac.uk [152.78.128.20]) by beech.soton.ac.uk (8.6.12/hub-8.5a) with ESMTP id NAA09625 for ; Mon, 30 Oct 1995 13:41:36 GMT Received: (from srk _-at-_)localhost) by willow.soton.ac.uk (8.6.10/client-8.8) id NAA26423 for CHEMISTRY $#at#$ www.ccl.net; Mon, 30 Oct 1995 13:37:43 GMT Message-Id: <199510301337.NAA26423 #at# willow.soton.ac.uk> Subject: bug in IRIX 4 C compiler To: CHEMISTRY -x- at -x- www.ccl.net Date: Mon, 30 Oct 1995 13:37:43 +0000 (GMT) From: "Simon Kilvington" X-Mailer: ELM [version 2.4 PL23] Content-Type: text Content-Length: 1412 hello, this is probably not the right place to post this - so, sorry in advance. anyway, onto the problem - it's not serious - the correct code is generated - but you get a warning message cuz the compiler gets confused about function argument types. the shortest program to demonstrate it is... /* bug.c */ char proc1(char); char proc2(char); void warning(int choice) { char (*proc)(char); proc = (choice) ? proc1 : proc2; } when you compile it "cc -c bug.c" the following warnings are generated... accom: Warning 294: bug.c, line 11: Function has prototyped and non-prototyped declarations. Default promotion of non-prototype form of argument 1 does not match prototype: prototype: char is different from actual: int proc = (choice) ? proc1 : proc2; ----------------------------------^ accom: Warning 196: bug.c, line 11: function prototypes are not equivalent; function pointer assignment invalid proc = (choice) ? proc1 : proc2; ----------------------------------^ for some reason it thinks the last argument to "proc1" and "proc2" should be an int. if you write... if(choice) proc = proc1; else proc = proc2; instead, all is well. the compilers with IRIX 5 and IRIX 6 don't have this trouble, and as I said before, the correct code is generated - so it's more annoying rather than anything else. --- Simon Kilvington, srk[ AT ]soton.ac.uk