Ok, here is a patch which improves the example:

--- gcc/doc/extend.texi.ORIG    2011-12-20 17:35:32.236578828 -0800
+++ gcc/doc/extend.texi    2011-12-20 17:37:10.460583316 -0800
@@ -7932,7 +7932,7 @@
 
 @smallexample
 if (__builtin_expect (ptr != NULL, 1))
-  error ();
+  ptr->do_something();
 @end smallexample
 
 @noindent




________________________________
From: Jonathan Wakely <jwakely....@gmail.com>
To: Segher Boessenkool <seg...@kernel.crashing.org> 
Cc: james_av...@yahoo.com; gcc@gcc.gnu.org 
Sent: Tuesday, December 20, 2011 5:22 AM
Subject: Re: Possible wrong-way example in gcc4-4-2 documentation of 
__builtin_expect

On 20 December 2011 12:49, Segher Boessenkool wrote:
>
> The point of the example is that you cannot write
>
>          if (__builtin_expect (ptr, 1))
>            error ();
>
> so the "!= NULL" is important here.  But you are right that
> "error ()" is a bit unexpected; care to send a patch that changes
> it to e.g. "do_something ()"?

or even ptr->do_something() since that would depend on the value of ptr

Reply via email to