gcc wont compile code with ?: operator

John V. Pope jpope_rhn at popes.net
Mon Feb 16 16:46:12 UTC 2004


On Mon, Feb 16, 2004 at 09:35:46AM -0700, Steve Wampler wrote:
> On Mon, 2004-02-16 at 09:32, John V. Pope wrote:
> > I was coding a simple C program and I found a bug in the gcc compiler.
> > 
> > The following code is a simple demonstration of the bug and should compile without errors:
> > 
> 
> > 		isprint(a[x]) ? b[x] = a[x]: b[x] = '.';
> 
> Check the precedence rules between = and ?:.
> -- 
> Steve Wampler -- swampler at noao.edu
> The gods that smiled on your birth are now laughing out loud.

Steve,

Adding parens, like so

isprint(a[x]) ? (b[x] = a[x]) : (b[x] = '.');

does allow it to compile but this was never needed before as far as I can recall.

Thanks,
John V. Pope





More information about the users mailing list