[Bug c/57647] New: lvalue required as increment operand

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

Bug ID: 57647
   Summary: lvalue required as increment operand
   Product: gcc
   Version: 4.7.2
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vijunag at gmail dot com

I recently upgraded my gcc compiler from 3.4.X to 4.7.2 for my project.

Consider the following expression

char *foo = bar;
((unsigned long*)foo)++

While gcc 3.4.X was more forgiving of this issue, 4.7.2 barfs out an error
lvalue required as increment operand.

I did notice in gcc documentation that cast as l-value has been removed.

C and Objective-C

The -Wstrict-aliasing=2 option has been added. This warning catches all
unsafe cases, but it may also give a warning for some cases that are safe.
The cast-as-lvalue, conditional-expression-as-lvalue and
compound-expression-as-lvalue extensions, which were deprecated in 3.3.4 and
3.4, have been removed.
The -fwritable-strings option, which was deprecated in 3.4, has been
removed.
#pragma pack() semantics have been brought closer to those used by other
compilers. This also applies to C++.
Taking the address of a variable with register storage is invalid in C. GCC
now issues an error instead of a warning.
Arrays of incomplete element type are invalid in C. GCC now issues an error
for such arrays. Declarations such as extern struct s x[]; (where struct s has
not been defined) can be moved after the definition of struct s. Function
parameters declared as arrays of incomplete type can instead be declared as
pointers.

So the natural fix and equivalent legitimate expression for the same would 
((unsigned long *)foo++), however with -Wall gcc again warns about
unused-value.

While gcc accepts the expression ((unsigned long*)foo++), the expression has
become useless when -Wall -Werror  is turned on since it throws
-Werror=unused-value.

Either the expression should completely be removed or GCC should stop warning
about such expressions.


[Bug c/57647] lvalue required as increment operand

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

--- Comment #2 from vijay Nag vijunag at gmail dot com ---
(In reply to Marek Polacek from comment #1)
 While 4.7 issues warning: value computed is not used, 4.8 and 4.9 do not for
 int
 main ()
 {
   char bar = 4;
   char *foo = bar;
   (unsigned long *)foo++;
   return 0;
 }
 
 For 4.7, you can just add cast to void
 (void) (unsigned long *)foo++;
 to silence the warning.

Does it work only for int or any type ?


[Bug c/57647] lvalue required as increment operand

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

--- Comment #4 from vijay Nag vijunag at gmail dot com ---
(In reply to Marek Polacek from comment #3)
 It should work for any type, but, why don't you do only foo++;, i.e. drop
 the cast?  In that case there shouldn't be value computed is not used
 warning.

Pointer Arithmetic.
I want to advance the pointer by sizeof(unsigned long) but not by sizeof(char).


[Bug c/57647] lvalue required as increment operand

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

--- Comment #6 from vijay Nag vijunag at gmail dot com ---
(In reply to Andreas Schwab from comment #5)
 ((unsigned long*)foo)++ and ((unsigned long *)foo++) are not equivalent
 expressions.  The former is the same as foo = (char *)((unsigned long*)foo +
 1), the latter is foo += sizeof(*foo) (and the cast has no effect).

((unsigned long*)foo)++ is no longer a valid C expression for the cast
evaluates it to be an R-value rather than L-value


[Bug c/57647] lvalue required as increment operand

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

--- Comment #7 from vijay Nag vijunag at gmail dot com ---
(In reply to vijay Nag from comment #6)
 (In reply to Andreas Schwab from comment #5)
  ((unsigned long*)foo)++ and ((unsigned long *)foo++) are not equivalent
  expressions.  The former is the same as foo = (char *)((unsigned long*)foo +
  1), the latter is foo += sizeof(*foo) (and the cast has no effect).
 
((unsigned long*)foo)++ is no longer a valid C expression for the cast
evaluates it to be an R-value rather than L-value.  Why is the second
expression
evaluating as foo += sizeof(*foo) ? ()(parentheses) comes before ++(postfix)
although they both have the same precedence  but associativity is from left to
right.


[Bug rtl-optimization/57635] gcc hanging while compiling huge files

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

--- Comment #2 from vijay Nag vijunag at gmail dot com ---
With the compiler flag -fno-var-tracking, it compiles in less than a minute.
Although it is quite conspicuous from back-trace I thought it is worth
mentioning this info.


[Bug c/57635] New: gcc hanging while compiling huge files

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

Bug ID: 57635
   Summary: gcc hanging while compiling huge files
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vijunag at gmail dot com

to gcc
Hello,

I recently upgraded my compiler to 4.7.2 and I'm trying to compile a huge file
containing as much as 92840 lines and gcc is taking an eternity to compile.
(more than 18 hours)

I see via top command that CC1 is consuming 100 percent CPU.

 PID USER  PR  NI  VIRT  RES  SHR S %CPU %MEMTIME+  COMMAND 
14848 vinag 25   0  485m 413m 8196 R 99.9  0.4  64:41.24 cc1 

I tried to attach to CC1 in gdb and below are few snapshots of it under gdb

snapshot 1
Program received signal SIGINT, Interrupt.
0x0052f775 in find_base_term ()
(gdb) bt
#0  0x0052f775 in find_base_term ()
#1  0x0052f924 in find_base_term ()
#2  0x0052fa45 in base_alias_check ()
#3  0x00531823 in true_dependence_1 ()
#4  0x00531a31 in canon_true_dependence ()
#5  0x005acf58 in cselib_invalidate_mem ()
#6  0x005ad14c in cselib_invalidate_rtx ()
#7  0x005ad170 in cselib_invalidate_rtx_note_stores ()
#8  0x00816458 in note_stores ()
#9  0x005ad935 in cselib_record_sets ()
#10 0x005add94 in cselib_process_insn ()
#11 0x00a4b78a in vt_initialize ()
#12 0x00a4beda in variable_tracking_main_1 ()
#13 0x00a4be47 in variable_tracking_main ()
#14 0x007a6b89 in execute_one_pass ()
#15 0x007a6ef8 in execute_pass_list ()
#16 0x007a6f16 in execute_pass_list ()
#17 0x007a6f16 in execute_pass_list ()
#18 0x008ddc76 in tree_rest_of_compilation ()
#19 0x005a0a28 in cgraph_expand_function ()
#20 0x005a0be4 in cgraph_expand_all_functions ()
#21 0x005a14f0 in cgraph_optimize ()
#22 0x0059f498 in cgraph_finalize_compilation_unit ()
#23 0x0049d927 in c_write_global_declarations ()
#24 0x0087865e in compile_file ()
#25 0x0087a8e7 in do_compile ()
#26 0x0087aa34 in toplev_main ()
#27 0x0052a17f in main ()
(gdb) c
Continuing.

snapshot2
(gdb) bt
#0  0x0052f7ea in find_base_term ()
#1  0x0052f924 in find_base_term ()
#2  0x0052f7cf in find_base_term ()
#3  0x0052f924 in find_base_term ()
#4  0x0052fa45 in base_alias_check ()
#5  0x00531823 in true_dependence_1 ()
#6  0x00531a31 in canon_true_dependence ()
#7  0x005acf58 in cselib_invalidate_mem ()
#8  0x005ad14c in cselib_invalidate_rtx ()
#9  0x005ad170 in cselib_invalidate_rtx_note_stores ()
#10 0x00816458 in note_stores ()
#11 0x005ad935 in cselib_record_sets ()
#12 0x005add94 in cselib_process_insn ()
#13 0x00a4b78a in vt_initialize ()
#14 0x00a4beda in variable_tracking_main_1 ()
#15 0x00a4be47 in variable_tracking_main ()
#16 0x007a6b89 in execute_one_pass ()
#17 0x007a6ef8 in execute_pass_list ()
#18 0x007a6f16 in execute_pass_list ()
#19 0x007a6f16 in execute_pass_list ()
#20 0x008ddc76 in tree_rest_of_compilation ()
#21 0x005a0a28 in cgraph_expand_function ()
#22 0x005a0be4 in cgraph_expand_all_functions ()
#23 0x005a14f0 in cgraph_optimize ()
#24 0x0059f498 in cgraph_finalize_compilation_unit ()
#25 0x0049d927 in c_write_global_declarations ()
#26 0x0087865e in compile_file ()
#27 0x0087a8e7 in do_compile ()
#28 0x0087aa34 in toplev_main ()
#29 0x0052a17f in main ()

I'm little bit surprised because same file I was able to compile with my older
gcc compiler 3.3.

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

[Bug c/57635] gcc hanging while compiling huge files

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

--- Comment #1 from vijay Nag vijunag at gmail dot com ---
Let me know if you will need any additional information. It is also difficult 
to isolate one single huge file from my project to attach it here. It will be
great if you can suggest me to proceed in some direction to debug this issue.


[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 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 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] New: lvalue required with comma operator

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

Bug ID: 57531
   Summary: lvalue required with comma operator
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vijunag at gmail dot com

Following expression cannot be compiled using gcc-4.7.2 where as the same
statement is perfectly acceptable by gcc version 4.4.5
 (void) 0, a = b;

[vinag]$ ~/tools/bintools/linux-x86/gcc/201302221200/bin/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=/ws/vinag-bgl/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) 

Program:

vijay:/home/vijay]$ cat ternary.c

#include stdio.h

int main()
{
  int a;
  (void )0, a = 4;
}
[vijay]i686-pc-linux-gnu-gcc lvalue.cpp -c
lvalue.cpp: In function ‘void lvalue_assignment()’:
lvalue.cpp:6:27: error: lvalue required as left operand of assignment

vijay:/home/vijay]$ gcc ternary.c -o ternary.c.out
vijay:/home/vijay]$ gcc -v
Using built-in specs.
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
4.4.4-14ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc
--enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic
--enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu
--target=i686-linux-gnu
Thread model: posix
gcc version 4.4.5 (Ubuntu/Linaro 4.4.4-14ubuntu5)

[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