Null characters in file

Zack Weinberg zack@wolery.cumb.org
Tue Apr 4 10:11:00 GMT 2000


On Tue, Apr 04, 2000 at 09:44:27AM +0200, Gunther Nikl wrote:
> Jason Merrill writes:
> > Per Bothner <per@bothner.com> writes:
> >
> > > I don't think it is reasonable to have an embedded null in a string.
> > > The nul character is not in the C source character set.
> > > I feel there should be warning, perhaps a pedwarn.
> 
> > OK, perhaps "reasonable" was too strong. A warning does make sense. But
> > the null should be passed through.
> 
>   Do you really think a NUL character is accidently in a string? Concatening
>   two strings that way is not uncommon. IMHO, there shouldn't be a warning
>   about this. If at all then only an request and not with -Wall (or -W).

You may be confusing the common idiom

char str[] = "abcdef\0ghijkl";

which no one wants warned about, with the case under discussion.  We
are talking about

char str[] = "abcdef^@ghijkl";

where there is actually a binary zero byte in the source file.  That
is far less common, and almost certainly a mistake.  That's what we
are considering adding a warning for.

zw


More information about the Gcc-patches mailing list