[Bug c++/47541] New: For integer pointers, the value of ++*p is not written back to memory

2011-01-30 Thread veksler at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47541

   Summary: For integer pointers, the value of ++*p  is not
written back to memory
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: veks...@il.ibm.com


The problem occurs in a copy constructor both for 386 and for X86-64. This is a
copy constructor of a reference counting object which uses int* to keep 
track of the number of copies of an "A" object. The copy constructor messes up,
it calculates the new count (in some cases), but forgets to write it back to
the int*.

The attached test case is a bit complicated, yet it is a simplification of real
code. There are two options to see the issue:
  $ g++ -O2 -g refcount.cpp && ./a.out
  Segmentation fault (core dumped)

  $ g++ -O2 -DTRACE -g refcount.cpp && ./a.out
  A::A()
  RefCount()
  count=1
  RefCount(const RefCount&)
  count=1
  ~RefCount()
  A::~A
  count=0
  Segmentation fault (core dumped)

As you can see, the reference is not incremented when it should be.

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.5.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.5.1 20100924 (Red Hat 4.5.1-4) (GCC)


[Bug c++/47541] For integer pointers, the value of ++*p is not written back to memory

2011-01-30 Thread veksler at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47541

Michael Veksler  changed:

   What|Removed |Added

Version|4.5.1   |4.6.0

--- Comment #1 from Michael Veksler  2011-01-30 
09:39:50 UTC ---
I recreated this bug, with the same attachment, for 4.6.0 20110129
(experimental):

Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.6-20110129/configure--enable-languages=c++
Thread model: posix
gcc version 4.6.0 20110129 (experimental) (GCC) 


Updating the version accordingly. 

Also, it seems to me that this worked fine with the gcc-4.4 series (I was able
to work with that code just fine with fc13 which, as far as I can remember,
comes with gcc-4.4). In that case, this is a regression.


[Bug c++/47541] For integer pointers, the value of ++*p is not written back to memory

2011-01-30 Thread veksler at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47541

--- Comment #3 from Michael Veksler  2011-01-30 
12:39:04 UTC ---
Created attachment 23168
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23168
This is a minimal file to reproduce this error

Strange, it got lost somehow. Here it is, again.


[Bug gcov-profile/51484] New: Can't create C++ executable with -profile-generate

2011-12-09 Thread veksler at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51484

 Bug #: 51484
   Summary: Can't create C++ executable with -profile-generate
Classification: Unclassified
   Product: gcc
   Version: 4.7.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: veks...@il.ibm.com


Hello,

How can I turn profile driven optimizations with gcc-4.7.0 development version?
It used to work with gcc-4.6.x and before. I am trying to use the latest GCC
trunk:
$ /opt/gcc47-20111207/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/opt/gcc47-20111207/bin/g++
COLLECT_LTO_WRAPPER=/opt/gcc47-20111207/libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-source/configure --prefix=/opt/gcc47-20111207
--enable-languages='c++ c'
Thread model: posix
gcc version 4.7.0 20111206 (experimental) (GCC)


I have got two files:
// t.cpp
#include
void f() { std::cout<<  "hello\n"; }


// t.cpp
void f();
int main() { f(); return 0; }


I compile them with:
$ rm -rf prof
$ /opt/gcc47-20111207/bin/g++ -c t.cpp -g -O2 -m32 -fprofile-generate=prof


$ /opt/gcc47-20111207/bin/g++ -c t2.cpp -g -O2 -m32 -fprofile-generate=prof

$ /opt/gcc47-20111207/bin/g++ -O2 t2.o t.o -g -m32 -fprofile-generate=prof

and I get:
= begin 
/home/me/t2.cpp:3: undefined reference to
`__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc'
/home/me/t2.cpp:3: undefined reference to
`__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc'
t2.o: In function `operator<<>':
/opt/gcc47-20111207/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:515:
undefined reference to
`__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc'
/opt/gcc47-20111207/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:515:
undefined reference to
`__gcov0__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc'
collect2: error: ld returned 1 exit status
== end 


Neither adding -lgcov at the end nor adding
/opt/gcc47-20111207/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/32/libgcov.a
helps.


[Bug c++/55639] Partial nested template specialization leads to segmentation fault of g++

2012-12-10 Thread veksler at il dot ibm.com


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



Michael Veksler  changed:



   What|Removed |Added



 CC||veksler at il dot ibm.com



--- Comment #2 from Michael Veksler  2012-12-10 
14:18:07 UTC ---

I have a possibly similar test case (can someone confirm if my case is a DUP?).





--- t.cpp --

template 

struct A {

   template 

   struct B;

};



template 

struct A::template B<0> {

   int foo();

};



 end --



$ /opt/gcc4.7.2/bin/g++ t.cpp

t.cpp:8:23: internal compiler error: Segmentation fault

Please submit a full bug report,

with preprocessed source if appropriate.

See <http://gcc.gnu.org/bugs.html> for instructions.



$/opt/gcc4.7.2/bin/g++ -v

Using built-in specs.

COLLECT_GCC=/opt/gcc4.7.2/bin/g++

COLLECT_LTO_WRAPPER=/opt/gcc4.7.2/libexec/gcc/x86_64-unknown-linux-gnu/4.7.2/lto-wrapper

Target: x86_64-unknown-linux-gnu

Configured with: ../gcc-4.7.2/configure --prefix=/opt/gcc4.7.2

Thread model: posix

gcc version 4.7.2 (GCC)


[Bug c++/49481] New: Warn about string literal + character

2011-06-20 Thread veksler at il dot ibm.com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49481

   Summary: Warn about string literal + character
   Product: gcc
   Version: 4.5.1
Status: UNCONFIRMED
  Severity: enhancement
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: veks...@il.ibm.com


Consider:

  void f(const std::string &a, std::string & b)
  {
 b+= "_" + a[1];
  }

Although syntactically correct, this code is most certainly buggy:
this is not Java and "_" is not a string object.

When compiling C++, and maybe C,  and gcc encounteres
operator+  
it should issue a warning.