Path: utzoo!utgpu!attcan!uunet!seismo!esosun!ucsdhub!ucsd!net1!hutch From: hutch@net1.ucsd.edu (Jim Hutchison) Newsgroups: comp.unix.questions Subject: Re: alloca problem? Keywords: alloca stack 386 sysv Message-ID: <1239@ucsd.EDU> Date: 7 Nov 88 05:10:26 GMT References: <17026@santra.UUCP> Sender: nobody@ucsd.EDU Reply-To: hutch@net1.UUCP (Jim Hutchison) Organization: some Lines: 41 If the code below would pass an ANSI-ized type checking, I can see no problem. On the other hand, it looks like a relatively easy-to-make typing error (not typography, type). Are integers different from pointers? For instance, are integers aligned? Are pointers? Are they the same size? Do pointers require extra processing due to some unusual characteristic in the architecture? If alloca() is not declared a (char *) in the code of the failing example, it will/should generate a different bit of code to handle the way its return value is placed on the stack. Try adding an: extern char *alloca(); Hopefully this will make the difference you were wanting. In article <17026@santra.UUCP> hsu@santra.UUCP (Heikki Suonsivu) writes: >Why this fails, > >huu(name) > char *name; >{ > char *d; > > d = strcpy(alloca(strlen(name) + 1), name); >} > >but this works? > >huu(name) > char *name; >{ > char *d; > > d = alloca(strlen(name) + 1); > strcpy(d, name); >} /* Jim Hutchison UUCP: {dcdwest,ucbvax}!cs!net1!hutch ARPA: JHutchison@ucsd.edu These are my opinions, and now you have your perceptions of them. */