This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]