This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GCC's statement expression extension


   From: Jamie Lokier <egcs@tantalophile.demon.co.uk> 
   Date: Fri, 4 Aug 2000 13:35:25 +0200 

   [Mark: the toupper example is not correct]

Indeed, please read on.

   Here is an example using Glibc's <bits/string2.h> implementation of
   strcmp.  (Work through the mass of __builtin_constant_p to the
   __strcmp_cg call).

     printf ("%s", (!strcmp ("yes", (a+b).c_str())) ? "equal" : "not equal");

Note that glibc leaves out a lot of its optimizations that use
statement expressions for C++.  Among these are tolower and toupper
(which are inlines for C++), and all of the string optimizations in
bits/string.h and bits/string2.h.

The only macro's that use statement expressions in <string.h> that are
used for C++ are strdupa and strndupa.  And these look to me as things
that would be impossible to implement using inlines.

Mark, please make sure that what you're saying about glibc in the
documentation is accurate.  Feel free to keep the comment if you can
find a *real* example where the semantics are problematic.  Otherwise,
replace the reference to the GNU C Library with a concrete example of
a statement expression that has problems.

Mark

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]