alloca problem?
Jim Hutchison
hutch at net1.ucsd.edu
Mon Nov 7 15:10:26 AEST 1988
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 at santra.UUCP> hsu at 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 at ucsd.edu
These are my opinions, and now you have your perceptions of them. */
More information about the Comp.unix.questions
mailing list