<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: gcc feature breaks glibc feature</title>
	<atom:link href="http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/</link>
	<description>a lowercase manifesto</description>
	<pubDate>Fri, 21 Nov 2008 11:55:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: David Schleef</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-390</link>
		<dc:creator>David Schleef</dc:creator>
		<pubDate>Mon, 01 Oct 2007 19:32:21 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-390</guid>
		<description>This feature certainly would suck if I wanted to override printf() at some time.  Maybe, say, when I was using gdb.</description>
		<content:encoded><![CDATA[<p>This feature certainly would suck if I wanted to override printf() at some time.  Maybe, say, when I was using gdb.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: desrt</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-389</link>
		<dc:creator>desrt</dc:creator>
		<pubDate>Mon, 01 Oct 2007 15:46:47 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-389</guid>
		<description>i'm not suggesting that i'd ever use "%s", NULL in code intended to be portable (or even in production code).  it's just handy for debugging output and the like when you toss in a quick printf() to see what's going on.</description>
		<content:encoded><![CDATA[<p>i&#8217;m not suggesting that i&#8217;d ever use &#8220;%s&#8221;, NULL in code intended to be portable (or even in production code).  it&#8217;s just handy for debugging output and the like when you toss in a quick printf() to see what&#8217;s going on.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Havoc</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-387</link>
		<dc:creator>Havoc</dc:creator>
		<pubDate>Mon, 01 Oct 2007 14:26:57 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-387</guid>
		<description>This glibc feature is nothing but annoying, since it's unportable, all it does is keep you from noticing the bug until someone ports to another libc...</description>
		<content:encoded><![CDATA[<p>This glibc feature is nothing but annoying, since it&#8217;s unportable, all it does is keep you from noticing the bug until someone ports to another libc&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Qball</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-385</link>
		<dc:creator>Qball</dc:creator>
		<pubDate>Mon, 01 Oct 2007 12:19:29 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-385</guid>
		<description>This "feature"  has caused me headaches when cross-compiling/running programs on windows, there it will just crash.</description>
		<content:encoded><![CDATA[<p>This &#8220;feature&#8221;  has caused me headaches when cross-compiling/running programs on windows, there it will just crash.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: blah</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-382</link>
		<dc:creator>blah</dc:creator>
		<pubDate>Mon, 01 Oct 2007 12:09:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-382</guid>
		<description>Using a construct like printf("%s", NULL) in Gtk+ programs should be considered a bug anyway, unfortunately. On Solaris and other Unixes this construct will always cause a segfault.

I think GLib should provide something macroish like this:

static inline char *G_NONULLSTR(const char *s) {
    return s ? s : "(null)";
}

Then, people could just write:

printf("%s\n", G_NONULLSTR(s));

Which is relatively readable, safe and even type-safe.

On the Solaris printf() issue, see this:

http://mail.opensolaris.org/pipermail/opensolaris-code/2006-July/thread.html#2972

Unfortunately the Solaris people refused to copy glibc on this issue and kept their segfault-on-null printf implementation.</description>
		<content:encoded><![CDATA[<p>Using a construct like printf(&#8221;%s&#8221;, NULL) in Gtk+ programs should be considered a bug anyway, unfortunately. On Solaris and other Unixes this construct will always cause a segfault.</p>
<p>I think GLib should provide something macroish like this:</p>
<p>static inline char *G_NONULLSTR(const char *s) {<br />
    return s ? s : &#8220;(null)&#8221;;<br />
}</p>
<p>Then, people could just write:</p>
<p>printf(&#8221;%s\n&#8221;, G_NONULLSTR(s));</p>
<p>Which is relatively readable, safe and even type-safe.</p>
<p>On the Solaris printf() issue, see this:</p>
<p><a href="http://mail.opensolaris.org/pipermail/opensolaris-code/2006-July/thread.html#2972" rel="nofollow">http://mail.opensolaris.org/pipermail/opensolaris-code/2006-July/thread.html#2972</a></p>
<p>Unfortunately the Solaris people refused to copy glibc on this issue and kept their segfault-on-null printf implementation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: 1052</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-381</link>
		<dc:creator>1052</dc:creator>
		<pubDate>Mon, 01 Oct 2007 08:56:57 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-381</guid>
		<description>It seems obvious to me that glibc should handle puts() in the same way it handles printf(), and it should do the same with any other function that may print a null string. It is called consistency. So open a bug report there http://sources.redhat.com/bugzilla/enter_bug.cgi</description>
		<content:encoded><![CDATA[<p>It seems obvious to me that glibc should handle puts() in the same way it handles printf(), and it should do the same with any other function that may print a null string. It is called consistency. So open a bug report there <a href="http://sources.redhat.com/bugzilla/enter_bug.cgi" rel="nofollow">http://sources.redhat.com/bugzilla/enter_bug.cgi</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Elstner</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-380</link>
		<dc:creator>Daniel Elstner</dc:creator>
		<pubDate>Mon, 01 Oct 2007 08:05:02 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-380</guid>
		<description>&lt;blockquote&gt;
most gnome hackers are probably accustomed to the fact that they can pass a null pointer as a value to glibc’s “%s” conversion character and get the string “(null)” output instead of a crash.
&lt;/blockquote&gt;
I take offense at that assertion!

Just kidding. Seriously though, this is definitely not something one should be accustomed to do. Not everyone is using GNU libc.</description>
		<content:encoded><![CDATA[<blockquote><p>
most gnome hackers are probably accustomed to the fact that they can pass a null pointer as a value to glibc’s “%s” conversion character and get the string “(null)” output instead of a crash.
</p></blockquote>
<p>I take offense at that assertion!</p>
<p>Just kidding. Seriously though, this is definitely not something one should be accustomed to do. Not everyone is using GNU libc.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Aivars</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-379</link>
		<dc:creator>Aivars</dc:creator>
		<pubDate>Mon, 01 Oct 2007 08:04:08 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-379</guid>
		<description>Printing NULL is a common crasher on SunOS and looks like AIX and HP-UX treat NULL as zero length string.
I agree with Matt that programmers must check for NULL pointers.</description>
		<content:encoded><![CDATA[<p>Printing NULL is a common crasher on SunOS and looks like AIX and HP-UX treat NULL as zero length string.<br />
I agree with Matt that programmers must check for NULL pointers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Walton</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-378</link>
		<dc:creator>Matt Walton</dc:creator>
		<pubDate>Mon, 01 Oct 2007 06:38:56 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-378</guid>
		<description>Surely you should be using printf("%s\n", s ? s : "(null)"); anyway? Relying on that feature of glibc is going to bite you next time you need to compile something against a C library which doesn't behave like that.

It's also possible it might encourage a cavalier attitude towards null pointers which is not reflected in other parts of the library or other libraries, leading to a lack of care and greater risk of segfaults. One thing programming commercially does teach is that too many people don't pay attention to their pointers being null.

That said, by spec, is the optimisation valid in the defined behavioural cases? Best not to complain to the implementers about undefined ones - the language/library spec is at fault there.

Wouldn't it be nice to live in a world where there were no undefined cases in C...</description>
		<content:encoded><![CDATA[<p>Surely you should be using printf(&#8221;%s\n&#8221;, s ? s : &#8220;(null)&#8221;); anyway? Relying on that feature of glibc is going to bite you next time you need to compile something against a C library which doesn&#8217;t behave like that.</p>
<p>It&#8217;s also possible it might encourage a cavalier attitude towards null pointers which is not reflected in other parts of the library or other libraries, leading to a lack of care and greater risk of segfaults. One thing programming commercially does teach is that too many people don&#8217;t pay attention to their pointers being null.</p>
<p>That said, by spec, is the optimisation valid in the defined behavioural cases? Best not to complain to the implementers about undefined ones - the language/library spec is at fault there.</p>
<p>Wouldn&#8217;t it be nice to live in a world where there were no undefined cases in C&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rwg</title>
		<link>http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-376</link>
		<dc:creator>rwg</dc:creator>
		<pubDate>Mon, 01 Oct 2007 05:50:10 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/desrt/2007/10/01/gcc-feature-breaks-glibc-feature/#comment-376</guid>
		<description>Unfortunately, the gcc folks seem unwilling to fix this since they say the results of printf("%s\n", NULL) are undefined:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15685

(It would be nice to see consistency between gcc and glibc.)

It looks like your choices are -fno-builtin-printf or printf("%s\n", s ? s : "(null)");</description>
		<content:encoded><![CDATA[<p>Unfortunately, the gcc folks seem unwilling to fix this since they say the results of printf(&#8221;%s\n&#8221;, NULL) are undefined:</p>
<p><a href="http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15685" rel="nofollow">http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15685</a></p>
<p>(It would be nice to see consistency between gcc and glibc.)</p>
<p>It looks like your choices are -fno-builtin-printf or printf(&#8221;%s\n&#8221;, s ? s : &#8220;(null)&#8221;);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
