[Bug c++/54348] confusing error reported for type mismatch in conditional expression : "error: no match for ternary 'operator?:' in 'false ?"
jason.vas.dias at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Aug 21 20:27:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54348
--- Comment #5 from Jason Vas Dias <jason.vas.dias at gmail dot com> 2012-08-21 20:27:36 UTC ---
Oops, I was interrupted adding this comment to my initial comment - will
respond
to subsequent commment next :
Incidentally, I found this issue while developing a C++-98 replacement for
C-99 designated initializers for specific structs with generated macros :
<code>
#include <string>
#include <list>
using namespace std;
struct strct
{
string name, items ;
strct (string n, string i) : name(n), items(i){}
};
#define tok(t) t
#define the_struct_strct_member( member, a0, a1, a2, a3 ) \
( (&(((struct strct*)0) -> member ) == &(((struct strct*)0) -> a0)) \
? a1 \
:( ( &(((struct strct*)0) -> member) == &(((struct strct*)0) -> a2) ) \
? a3 \
: NULL \
) \
)
#define struct_strct( a0, a1, a2, a3 ) \
( the_struct_strct_member( tok(name) , a0, a1, a2, a3 ), \
the_struct_strct_member( tok(items) , a0, a1, a2, a3 ) \
)
void f()
{
string myItems;
string myName("");
strct s struct_strct( items, myItems, name, myName ) ;
}
</code>
This works!
More information about the Gcc-bugs
mailing list