Reg: Deletion of char ptr resulting in segmentation fault - Double to string convertion

Tobias Burnus burnus@net-b.de
Sat Mar 29 08:11:00 GMT 2014


Questions not related to GCC should be written to gcc-help@ - and not to 
gcc-bugs@. While bugs should be submitted via Bugzilla.

emailstorbala wrote:
> 	double num = 23e45;
>
> 	buffer = new char[sizeof(double) + 1];

Here you allocate 9 bytes.

> 		sprintf(buffer, "%lf", num);

And here you are writing the string 
"23000000000000000602806197963719130677638070272.000000", which is 
longer than 8 characters.

Tobias



More information about the Gcc-bugs mailing list