Thread View: comp.bugs.misc
2 messages
2 total messages
Started by Ray Butterworth
Fri, 27 May 1988 16:39
PCC and char x[]={sizeof("abc")};
Author: Ray Butterworth
Date: Fri, 27 May 1988 16:39
Date: Fri, 27 May 1988 16:39
15 lines
796 bytes
796 bytes
For some reason, tsize() in mip's pftn.c is called with garbage
arguments when the type of the array is (char). The other types
seem to work correctly.
% cat xx.c
int x[] = { sizeof("abc") };
long y[] = { sizeof("abc") };
char z[] = { sizeof("abc") };
BSD% cc xx.c
"xx.c", line 3: compiler error: compiler takes size of function
SUN% cc xx.c
cc: Fatal error in /lib/ccom: Segmentation fault (core dumped)
Re: PCC and char x[]={sizeof("abc")};
Author: Chris Maltby
Date: Mon, 30 May 1988 06:07
Date: Mon, 30 May 1988 06:07
26 lines
1191 bytes
1191 bytes
In article <19100@watmath.waterloo.edu> rbutterworth (Ray Butterworth) writes:
> % cat xx.c
> int x[] = { sizeof("abc") };
> long y[] = { sizeof("abc") };
> char z[] = { sizeof("abc") };
> BSD% cc xx.c
> "xx.c", line 3: compiler error: compiler takes size of function
DYNIX% cc x.c
"xx.c", line 3: unknown size
It's being real smart, and assuming you want to initialise the
char array with "abc". Then it sees the sizeof - spew!
A workaround is:
char _z[] = "abc";
char z[] = { sizeof _z };
I guess the actual fix is to find the spot where it starts the
initialisation and stop it from screwing up.
--
Chris Maltby - Softway Pty Ltd (chris@softway.oz)
PHONE: +61-2-698-2322 UUCP: uunet!softway.oz!chris
FAX: +61-2-699-9174 INTERNET: chris@softway.oz.au
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