This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
gcc 4.3.0, -Wconversion and conditional operator
- From: Andriy Gapon <avg at icyb dot net dot ua>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 19 Sep 2008 18:31:02 +0300
- Subject: gcc 4.3.0, -Wconversion and conditional operator
void f(int x)
{
char c = x ? '|' : '/';
}
$ cc1: warnings being treated as errors
char.c: In function 'f':
char.c:3: error: conversion to 'char' from 'int' may alter its value
Exit 1
If I replace 'x' with a constant (0 or 1) in the condition, then the
code compiles.
I think gcc should be smarter here.
--
Andriy Gapon