[cfe-dev] _Generic compiles fine in c++ source

Aaron Ballman aaron at aaronballman.com
Sat Jan 18 08:23:49 PST 2014


Actually, I take that back, we treat it as a language extension (not
certain how I missed that). You should be seeing an extension warning:
"generic selections are a C11-specific feature" depending on your
compiler flags.

So I wouldn't file a bug just yet. What flags are you passing in to
the compiler?

~Aaron

On Sat, Jan 18, 2014 at 11:21 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> That appears to be a bug; if you'd like, you could file a bug report
> at http://llvm.org/bugs on it.
>
> Good catch!
>
> ~Aaron
>
> On Sat, Jan 18, 2014 at 2:48 AM, Prathamesh Kulkarni
> <bilbotheelffriend at gmail.com> wrote:
>> Hi, sorry to ask a daft question but why does the following code
>> compile fine with clang/clang++ ?
>>
>> int main()
>> {
>>   int a = _Generic(1, int: 2);
>>   int &x = a;
>> }
>>
>> As far as I know, it does not conform to either C or C++ ( I believe
>> _Generic is not supported by C++ ? ).
>> It fails to compile with g++.
>>
>> Thanks and Regards,
>> Prathamesh
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list