[Bug c/57531] lvalue required with comma operator

vijunag at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Jun 5 14:11:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

vijay Nag <vijunag at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c++                         |c
           Severity|normal                      |critical

--- Comment #2 from vijay Nag <vijunag at gmail dot com> ---
Sorry for the confusion. Please try the unit test case below

#include <stdio.h>

/*remove assert  in production*/

#define ASSERT(x) (void)0
#define GET_VALUE_A(value) ((value)->version == 1 ? ASSERT(value), (value)->b :
(value)->a)

struct Lvalue {
  int version;
  int a;
  int b;
};

int main()
{
  struct Lvalue lvalue = {};
  lvalue.version = 1;

  GET_VALUE_A(&lvalue) = 5;
}

i686-pc-linux-gnu-gcc -c ternary.c 
ternary.c: In function ‘main’:
ternary.c:19:24: error: lvalue required as left operand of assignment

i686-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=~/tools/bintools/linux-x86/gcc/201302221200/bin/i686-pc-linux-gnu-gcc-wrapped
COLLECT_LTO_WRAPPER=~/tools/bintools/linux-x86/gcc/201302221200/libexec/gcc/i686-pc-linux-gnu/4.7.2/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../../gcc/configure --build=amd64-pc-linux-gnu
--host=amd64-pc-linux-gnu --target=i686-pc-linux-gnu --enable-languages=c,c++
--prefix=~tools/bintools/linux-x86/gcc/201302221200 --enable-shared
--with-headers=/tmp/201302221200/new_header/ --disable-libquadmath
--disable-libgomp --disable-libssp --disable-libmudflap --disable-libitm
--with-fast-fixincludes --enable-threads --site=starent --with-gnu-as
--with-gnu-ld
Thread model: posix
gcc version 4.7.2 (GCC) 


i586-pc-linux-gnu-gcc -c ternary.c 
i586-pc-linux-gnu-gcc -v
Reading specs from
~/tools/bintools/linux-x86/gcc/200608191248/lib/gcc-lib/i586-pc-linux-gnu/3.3.6/specs
Configured with: ../../gcc/configure --build=i686-linux --host=i686-linux
--target=i586-pc-linux-gnu --enable-languages=c,c++
--prefix=~/tools/bintools/linux-x86/gcc/200608191248 --enable-shared
--with-headers=/localdisk/tmp/x86-linux/include --with-fast-fixincludes
--enable-threads --site=starent --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 3.3.6


More information about the Gcc-bugs mailing list