Pb with the new libc

Hi,

I found something strange with the new lib (the one that comes with 6.1A).

try something like
printf("%s\n", NULL);

You’ll get SIGSEGVed…

Before (6.0x) you had :
(null)


And of course I find this new behaviour very annoying :astonished:)

I thought it was ANSI to print (null) if the string pointer is NULL.

I didn’t try it on 6.1, but only in 6.1A.

Help (patch B) needed!


Didier HARRANG

Didier Harrang <didier.harrang@bcisa.com> wrote:

Hi,

I found something strange with the new lib (the one that comes with 6.1A).

try something like
printf("%s\n", NULL);

You’ll get SIGSEGVed…

Before (6.0x) you had :
(null)



And of course I find this new behaviour very annoying > :astonished:> )

I thought it was ANSI to print (null) if the string pointer is NULL.

Absolutely not. This is something which happens to be in some stdio
implementations but promotes bad programming habits. The standard
says a pointer to a null terminated string … if you don’t provide
a null terminated string then you have an error in your code.

Thomas

Thomas (toe-mah) Fletcher QNX Software Systems
thomasf@qnx.com Neutrino Development Group
(613)-591-0931 http://www.qnx.com/~thomasf

Didier Harrang <didier.harrang@bcisa.com> wrote:

try something like
printf("%s\n", NULL);

You’ll get SIGSEGVed…

Before (6.0x) you had :
(null)



And of course I find this new behaviour very annoying > :astonished:> )
I thought it was ANSI to print (null) if the string pointer is NULL.

In ANSI/ISO C, the %s format specifies that (in the correct position) a
pointer to a string must be present. This behaviour changed when we moved
to the Dinkum libraries (which is 6.1+).

-Adam