This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC's statement expression extension
- To: gcc at gcc dot gnu dot org, mark at codesourcery dot com
- Subject: Re: GCC's statement expression extension
- From: Mark Kettenis <kettenis at wins dot uva dot nl>
- Date: Fri, 4 Aug 2000 14:32:57 +0200 (MET DST)
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