[Bug c/57531] lvalue required with comma operator

2013-06-05 Thread vijunag at gmail dot com
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

[Bug c/57531] lvalue required with comma operator

2013-06-05 Thread vijunag at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

--- Comment #3 from vijay Nag vijunag at gmail dot com ---
(In reply to vijay Nag from comment #2)
 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

[Bug c/57531] lvalue required with comma operator

2013-06-05 Thread paolo.carlini at oracle dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

Paolo Carlini paolo.carlini at oracle dot com changed:

   What|Removed |Added

   Severity|critical|normal


[Bug c/57531] lvalue required with comma operator

2013-06-05 Thread vijunag at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

vijay Nag vijunag at gmail dot com changed:

   What|Removed |Added

 CC||vijunag at gmail dot com
   Severity|normal  |major


[Bug c++/57531] lvalue required with comma operator

2013-06-05 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

  Component|c   |c++
   Severity|major   |normal

--- Comment #4 from Andrew Pinski pinskia at gcc dot gnu.org ---
I think the problem is the comma operator causes it to be a rvalue.  In that
((void)0, x) is considered rvalue rather than what you want as a lvalue.

Note C does not have ?: as lvalues so this cannot apply to C; only C++.


[Bug c++/57531] lvalue required with comma operator

2013-06-05 Thread vijunag at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

--- Comment #5 from vijay Nag vijunag at gmail dot com ---
(In reply to Andrew Pinski from comment #4)
 I think the problem is the comma operator causes it to be a rvalue.  In that
 ((void)0, x) is considered rvalue rather than what you want as a lvalue.
 
 Note C does not have ?: as lvalues so this cannot apply to C; only C++.

Why did it work with gcc-3.3.6 ? Any revisions in standard ?


[Bug c++/57531] lvalue required with comma operator

2013-06-05 Thread sch...@linux-m68k.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

Andreas Schwab sch...@linux-m68k.org changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #6 from Andreas Schwab sch...@linux-m68k.org ---
This GCC extension has been removed in 4.0.


[Bug c/57531] lvalue required with comma operator

2013-06-04 Thread vijunag at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

vijay Nag vijunag at gmail dot com changed:

   What|Removed |Added

   Severity|normal  |critical


[Bug c++/57531] lvalue required with comma operator

2013-06-04 Thread pinskia at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57531

Andrew Pinski pinskia at gcc dot gnu.org changed:

   What|Removed |Added

   Severity|critical|normal

--- Comment #1 from Andrew Pinski pinskia at gcc dot gnu.org ---
Your small testcase works for me both in 4.7.0 and 4.9.0 (20130422).

Your lvalue.cpp does not correspond to your testcase your placed in the bug
report either.