Article View: gnu.gcc.help
Article #51255Alignment Error: Reference Function by Pointer in gcc
From: Ted A. Campbell
Date: Tue, 22 Jun 1993 19:13
Date: Tue, 22 Jun 1993 19:13
85 lines
3199 bytes
3199 bytes
I am currently debugging a new version of my Bywater BASIC interpreter.
When compiling the interpreter on a DECStation with gcc 3.xx, the interpreter
dumps a core each time I try to reference a function by pointer. This
is critical to the interpreter, because it uses a table of command names
and associated function pointers to reference the BASIC commands.
Previous versions compiled with these systems did not have this problem.
I'm wondering if there is an incantation that will force gcc to
align these function vectors correctly. I have isolated the offending
fragments of program in the example that follows (it also blows out
in the same way).
I shall be very grateful if someone can explain to me how I can
avoid this problem.
Ted A. Campbell
Duke University
tcamp@acpub.duke.edu
#include "stdio.h"
#include "stdlib.h"
/* Structure to represent program lines under Bywater BASIC */
struct bwb_line
{
struct bwb_line *next; /* pointer to next line in chain */
int number; /* line number */
char xnum; /* is there actually a line number? */
char *buffer; /* buffer to hold the line */
int position; /* current position in line */
int lnpos; /* line number position in buffer */
int lnum; /* line number read from buffer */
int cmdpos; /* command position in buffer */
int cmdnum; /* number of command in command table
read from buffer */
int startpos; /* start of rest of line read from buffer */
int marked; /* has line been checked yet? */
};
/* Structure to represent all command statements under Bywater BASIC */
struct bwb_command
{
char name[ 64 ];
struct bwb_line * (*vector) (struct bwb_line *);
};
extern struct bwb_line *testcmd( struct bwb_line *l );
struct bwb_command bwb_cmdtable[ 1 ] =
{
{ "TEST", testcmd }
};
void
main( int argc, char *argv[] )
{
struct bwb_command *c;
struct bwb_line *l;
printf( "Test vector to BASIC command.\n" );
( bwb_cmdtable[ 0 ].vector ) ( l );
printf( "This concludes our test.\n" );
}
struct bwb_line *
testcmd( struct bwb_line *l )
{
printf( "This is written from testcmd().\n");
return l->next;
}
--
Ted A. Campbell
Duke Divinity School
tcamp@acpub.duke.edu
Technical Details
Message-ID:
<16667@news.duke.edu>Path:
arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!darwin.sura.net!news-feed-1.peachnet.edu!concert!duke!news.duke.edu!acpub.duke.edu!tcampShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,2b759b940d6e0788,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-06-22 12:39:15 PST Path: arc1-ca.pugleaf.net!gmd.de!xlink.net!howland.reston.ans.net!darwin.sura.net!news-feed-1.peachnet.edu!concert!duke!news.duke.edu!acpub.duke.edu!tcamp From: tcamp@acpub.duke.edu (Ted A. Campbell) Newsgroups: gnu.gcc.help Subject: Alignment Error: Reference Function by Pointer in gcc Message-ID: <16667@news.duke.edu> Date: 22 Jun 93 19:13:27 GMT Sender: news@news.duke.edu Lines: 85 Nntp-Posting-Host: raphael.acpub.duke.edu