Article View: comp.sys.next.programmer
Article #690Re: NeXT-cc bug report
From: Ralf E. Stranzenbach
Date: Mon, 13 Apr 1992 22:08
Date: Mon, 13 Apr 1992 22:08
43 lines
1902 bytes
1902 bytes
In article <2121@transfer.stratus.com> dan@quiensabe.az.stratus.com
(Dan Danz) writes:
> In article <1992Apr8.183539.1868@talus.com> ajamison@talus.com
(Alex
> Senkevitch) writes:
> > In article <1992Apr7.084848.29747@reswi.en.open.de>
> > ralf@reswi.en.open.de (Ralf E. Stranzenbach) writes:
> > > the following code fragment did _not_ compile properly:
> > > void some_function (char * s)
> > > {
> > > char * d;
> > > d = strcpy (alloca (strlen (s) + 1), s);
> > > printf ("%s copied as %s\n", s, d);
> > > }
> > try this:
> > void some_function(char *s) {
> > char *d;
> > strcpy((d=(char*)malloc(strlen(s)+1)),s);
> > printf("%s copied as %s\n", s, d);
> > }
>
> I suspect that Ralf's original problem has to do with both the
compiler
> AND alloca trying to anipulate the stack pointer to create
> temporary space on the stack. This is one of the things that makes
alloca
> a difficult function to implement. Try it by doing the alloca call
first
> and then do the strcpy into d as a separate line of code.
As a marginal note: The code above (with alloca) works without
problems on gcc-2.0(i386). Something has been changed ? And it
_should_ work.... (allocating temporary strings).
- ralf
--
Ralf E.Stranzenbach - (NeXT)-Mail: ralf@reswi.en.open.de
Fido: via 2:245/5800.12
(Voice)-Phone: +49 2302 / 68403
--
MSDOS 486/50MHz:
15 Mips warten schneller.
Technical Details
Message-ID:
<1992Apr13.220801.29916@reswi.en.open.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!unido!horga!ruhr.de!reswi!ralfReferences:
<2121@transfer.stratus.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!unido!horga!ruhr.de!reswi!ralf From: ralf@reswi.en.open.de (Ralf E. Stranzenbach) Newsgroups: comp.sys.next.programmer Subject: Re: NeXT-cc bug report Message-ID: <1992Apr13.220801.29916@reswi.en.open.de> Date: 13 Apr 92 22:08:01 GMT References: <2121@transfer.stratus.com> Sender: ralf@reswi.en.open.de Organization: News on RESWI from ENtenhausen.OPEN.DE Lines: 43