Article View: gnu.g++.bug
Article #1507fatal signal on sparc
From: "Douglas C. Schmidt"
Date: Sun, 23 Oct 1988 20:14
Date: Sun, 23 Oct 1988 20:14
60 lines
1932 bytes
1932 bytes
Hi,
The following program gets a fatal signal when compiled on the Sun 4
running g++ 1.27. Furthermore, it also complains about struct state
not having a method named `next.' Since this works fine under gcc on
the Sun 3 I suppose there is a subtle distinction between structs in
C++ and C on this point. Can someone please explain why?
thanks,
Doug
----------------------------------------
#include <stdio.h>
struct state {
struct state (*next)(struct state);
};
int i = 0;
struct state foo(struct state Current)
{
if (i < 5) {
i++;
}
else {
Current.next = NULL;
}
return(Current);
}
state_machine(struct state initstate)
{
struct state state = initstate;
while (state.next)
state = state.next(state);
}
main()
{
struct state state = { foo };
printf("i == %d\n",i);
state_machine(state);
printf("i == %d\n",i);
}
----------------------------------------
g++ version 1.27.0
echo use .cc filename extension!
use .cc filename extension!
/usr/public/lib/g++/gcc-cpp+ -v -I/cd/ua/schmidt/include/ -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix -+ state.c /tmp/cca18377.cpp
GNU CPP version 1.27.0
/usr/public/lib/g++/gcc-c++ /tmp/cca18377.cpp -quiet -dumpbase state.c -fchar-charconst -version -o /tmp/cca18377.s
state.c:25: structure has no method named `next'
GNU C++ version 1.27.0 (sparc) compiled by GNU C version 1.28.
/usr/public/g++: Program c++ got fatal signal 6.
Technical Details
Message-ID:
<8810231313.aa19086@PARIS.ICS.UCI.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!ORION.CF.UCI.EDU!schmidt%blanche.ics.uci.eduShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!uunet!tut.cis.ohio-state.edu!ORION.CF.UCI.EDU!schmidt%blanche.ics.uci.edu
From: schmidt%blanche.ics.uci.edu@ORION.CF.UCI.EDU ("Douglas C. Schmidt")
Newsgroups: gnu.g++.bug
Subject: fatal signal on sparc
Message-ID: <8810231313.aa19086@PARIS.ICS.UCI.EDU>
Date: 23 Oct 88 20:14:06 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 60