gcc 2.95.2 bug: complex numbers and conditional op's don't mix
Gabriel Dos Reis
gdr@codesourcery.com
Sun Jun 4 14:41:00 GMT 2000
"Steven G. Johnson" <stevenj@superjdj.mit.edu> writes:
| Dear gcc folks,
|
| I get an error "type mismatch in conditional expression" in gcc 2.95.2 (on
| Linux/x86) when compiling the following trivial and valid program.
|
| The catch is that the program uses complex number types; it works fine if
| I use e.g. "double" instead, so this seems to be a bug in the complex
| number support.
|
| Don't hesitate to email me if you need any other information. I would
| also appreciate it if someone would try it in the latest CVS version of
| gcc and post whether they can reproduce the bug. Thanks!
Current CVS exhibites the same behaviour. The patch below fixes the
problem.
Bootstrap and tested on i686-pc-linux-gnu.
OK to commit?
I don't think the C++ front-end should be modified to accept the
construct.
-- Gaby
CodeSourcery, LLC http://www.codesourcery.com
2000-06-04 Gabriel Dos Reis <gdr@codesourcery.com>
* c-typeck.c (build_conditional_expr): Handle complex data types.
Index: c-typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/c-typeck.c,v
retrieving revision 1.67
diff -p -r1.67 c-typeck.c
*** c-typeck.c 2000/05/31 18:36:02 1.67
--- c-typeck.c 2000/06/04 21:31:30
*************** build_conditional_expr (ifexp, op1, op2)
*** 3359,3366 ****
else
result_type = TYPE_MAIN_VARIANT (type1);
}
! else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE)
! && (code2 == INTEGER_TYPE || code2 == REAL_TYPE))
{
result_type = common_type (type1, type2);
--- 3359,3368 ----
else
result_type = TYPE_MAIN_VARIANT (type1);
}
! else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE
! || code1 == COMPLEX_TYPE)
! && (code2 == INTEGER_TYPE || code2 == REAL_TYPE
! || code2 == COMPLEX_TYPE))
{
result_type = common_type (type1, type2);
More information about the Gcc-bugs
mailing list