gcc wont compile code with ?: operator

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:

--X-snip-X--
#include <stdio.h>

main()
{
char a[80];
char b[80];
int  x;

	for(x = 0; x < 80; x++)
	{
		/*
			This works just fine
		*/
		if(isprint(a[x]))
			b[x] = a[x];
		else
			b[x] = '.';

		/*
		 ?: operator won't compile
		gcc version 3.3.2 20031022 (Red Hat Linux 3.3.2-1)
		error: invalid lvalue in assignment
		*/
		isprint(a[x]) ? b[x] = a[x]: b[x] = '.';
	}
}
--X-snip-X--

As my sample shows, the compiler can't handle the ?: operator.

I have used the ?: operator many times over the past decade and expect it to work under gcc.

Does anyone have a clue what's going on?

Thanks,
John V. Pope




[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux