[cfe-dev] _Generic constant string as controlling expression
richard at metafoo.co.uk
Mon Dec 9 12:29:51 PST 2013
On Mon, Dec 9, 2013 at 12:26 PM, Zhihao Yuan <zy at miator.net> wrote:
> On Mon, Dec 9, 2013 at 3:17 AM, Richard Smith <richard at metafoo.co.uk>
> >> Since this clause has no mention for _Generic, shouldn't the type of
> >> "hello"
> >> be converted from char to char * when it's used as a controlling
> >> expression ?
> >> Or am I missing something ?
> > Yes, I think it should -- this looks like a bug. Please file a bug
> I don't think so. It looks more like an overlook to me. CC'ed Clark (the
> author of _Generic).
See also http://gcc.gnu.org/ml/gcc-patches/2013-07/msg00971.html and in
"The controlling expression of a generic selection was very carefully
not added to the list of contexts in which lvalue conversion is not
done and type qualification is discarded", the minutes [from the C
committee meeting] say
At a first glance, performing an array-to-pointer conversion make things
> easier, but imagine something like this:
> #define F(e) _Generic(e, char *: sizeof(e))
> So what, sizeof a pointer is the array length? This leads very obscure
> programs. Please don't. In unevalued context (stealing C++ term here),
> no convert should be performed.
> Here is an solution (no matter this is a bug in which side):
> Zhihao Yuan, ID lichray
> The best way to predict the future is to invent it.
> 4BSD -- http://4bsd.biz/
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev