[Bug c/64509] _Generic throws error in unselected generic association

2015-01-14 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64509

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #5 from Marek Polacek mpolacek at gcc dot gnu.org ---
(In reply to Martien de Jong from comment #4)
 BTW, I notice that
 
 ./gcc/ginclude/tgmath.h
 
 uses
 
 __builtin_classify_type
 __builtin_types_compatible_p
 __builtin_choose_expr
 
 Will it move to using _Generic() ?

I think it will over time (with a proper __GNUC_PREREQ guard).

Anyway, there is nothing to do for this bug, so closing.


[Bug c/64509] _Generic throws error in unselected generic association

2015-01-07 Thread maurits.de.jong at ericsson dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64509

--- Comment #4 from Martien de Jong maurits.de.jong at ericsson dot com ---
I understand. What a shallow and ugly feature it is then. I think it can only
usefully be employed using a preprocessor macro, yet it is part of the 
expression syntax. It is meant to resolve type issues, yet all variants
should be type-sane. You can indeed implement something like tgmath.h with it,
but only if the types can be implictly converted.

BTW, I notice that

./gcc/ginclude/tgmath.h

uses

__builtin_classify_type
__builtin_types_compatible_p
__builtin_choose_expr

Will it move to using _Generic() ?


[Bug c/64509] _Generic throws error in unselected generic association

2015-01-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64509

Marek Polacek mpolacek at gcc dot gnu.org changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #1 from Marek Polacek mpolacek at gcc dot gnu.org ---
I think it's fine to reject that testcase.  The type checking is performed when
parsing while building the association expression...


[Bug c/64509] _Generic throws error in unselected generic association

2015-01-06 Thread maurits.de.jong at ericsson dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64509

--- Comment #2 from Martien de Jong maurits.de.jong at ericsson dot com ---
That's just rephrasing my bugreport. The question is, should it type check
while parsing an expression that may not be realized? The entire idea of
switching on a type is to prevent and fix type errors, no?


[Bug c/64509] _Generic throws error in unselected generic association

2015-01-06 Thread joseph at codesourcery dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64509

--- Comment #3 from joseph at codesourcery dot com joseph at codesourcery dot 
com ---
_Generic is intended for cases like tgmath.h, where calls to all 
functions are still valid for all argument types.  This is a case where 
the expression __f(S) violates a constraint, and that constraint applies 
to all function calls, not just evaluated ones - this is just the same as 
a constraint violation inside if (0), or if 
(expression_that_evaluates_to_0_at_runtime).  (It's also required that 
functions called in unevaluated generic associations are defined somewhere 
in the program; only sizeof and _Alignof have exemptions from that.)