This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: char *p; placement and mysterious segfault on sprintf(p, "%d", 3);
On Mon, May 19, 2003 at 01:51:06PM -0400, Dave King wrote:
> Tom,
>
> If I read your response correctly, solution to this problem is to allocated
> enough space for the buffer p? Is this a bug in gcc or just not setting up
> sprintf correctly?
NO IT IS NO GCC BUG!
Every compiler must behave the same way. You programm is
incorrect. The "p" you are passing to "sprintf" is pointer pointing to
a, for all we know, *random* address. No space is allocated there.
/npat
--
A computer lets you make more mistakes faster than any invention in human
history, with the possible exceptions of handguns and tequila.
-- Mitch Ratcliffe, Technology Review, April 1992
- References:
- char *p; placement and mysterious segfault on sprintf(p, "%d", 3);
- Re: char *p; placement and mysterious segfault on sprintf(p, "%d",3);
- Re: char *p; placement and mysterious segfault on sprintf(p, "%d", 3);
- Re: char *p; placement and mysterious segfault on sprintf(p, "%d", 3);
- Re: char *p; placement and mysterious segfault on sprintf(p, "%d", 3);