[Bug c++/40059] New: "uninitialized" warning missed when uninitialized class member used as array index

2009-05-07 Thread gcc at dpinol dot com
Compiling this code with "g++-4.4 -O -Wall -g kk.cpp
-fdiagnostics-show-option"...
==
struct S
{
int a;
};

int main()
{
  S s;
  int i;
  bool arr[1];
  arr[s.a] =true;  /*line 11: missed*/  
  arr[i] = true;
/*  if (s.a)
return 1;
*/

  return 0;
}
==


produces
kk.cpp:12: warning: ‘i’ is used uninitialized in this function
[-Wuninitialized]

It realizes 1 bug, but not the one at line 11 (arr[s.a] =true)


However, if we uncomment the "if (s.a)" it does detect this usage of
uninitialized variable

kk.cpp:8: warning: ‘s.S::a’ is used uninitialized in this function
[-Wuninitialized]


thanks


-- 
   Summary: "uninitialized" warning missed when uninitialized class
member used as array index
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gcc at dpinol dot com


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



[Bug c++/36833] unexpected warning: guard 13936 owner may be used uninitialized in this function

2008-08-10 Thread gcc at dpinol dot com


--- Comment #3 from gcc at dpinol dot com  2008-08-11 06:33 ---
(In reply to comment #2)
> This warning is valid as far as I can tell as the compiler does not know
> ACE_OS::mutex_lock does not throw.
> 

Hi,
then why removing any of these 3 lines from CircularBuffer's constructor causes
the warning to disappear?
  c_pBufferStart( new int[ 10 ]),
  c_pBufferEnd( c_pBufferStart+10),
  m_pRead( (int*)c_pBufferStart ),

thanks


-- 


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



[Bug c++/36833] unexpected warning: guard 13936 owner may be used uninitialized in this function

2008-08-27 Thread gcc at dpinol dot com


--- Comment #5 from gcc at dpinol dot com  2008-08-27 10:05 ---
(In reply to comment #4)
> error: 'operator new' takes type 'size_t' ('long unsigned int') as first
> parameter

I don't understand why you get this error

> 
> What is the output of g++ -v ?
> 

See below. It eventually fails when linking because ACE libraries are not
added, but it compiles find

Thanks

$CXX -v main.ii
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.3.1src/configure --prefix=/opt/gcc431
--exec-prefix=/opt/gcc431
Thread model: posix
gcc version 4.3.1 (GCC)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
 /opt/gcc431/libexec/gcc/i686-pc-linux-gnu/4.3.1/cc1plus -fpreprocessed main.ii
-quiet -dumpbase main.   
ii -mtune=generic -auxbase main -version -o /tmp/ccXxeyeY.s
GNU C++ (GCC) version 4.3.1 (i686-pc-linux-gnu)
compiled by GNU C version 4.3.1, GMP version 4.2.1, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 2292e490ef57b0cdb59146a5820a2e88
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
 as -V -Qy -o /tmp/ccwWCoNY.o /tmp/ccXxeyeY.s
GNU assembler version 2.17.50.0.5 (i586-suse-linux) using BFD version
2.17.50.0.5 20060927 (SUSE Linux   
)
COMPILER_PATH=/opt/gcc431/libexec/gcc/i686-pc-linux-gnu/4.3.1/:/opt/gcc431/libexec/gcc/i686-pc-linux-g
  
nu/4.3.1/:/opt/gcc431/libexec/gcc/i686-pc-linux-gnu/:/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1/:/opt
  
/gcc431/lib/gcc/i686-pc-linux-gnu/
LIBRARY_PATH=/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1/:/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1/
  
../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-mtune=generic'
 /opt/gcc431/libexec/gcc/i686-pc-linux-gnu/4.3.1/collect2 --eh-frame-hdr -m
elf_i386 -dynamic-linker / 
  lib/ld-linux.so.2 /usr/lib/crt1.o /usr/lib/crti.o
/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1/crtbegin   
.o -L/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1
-L/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1/../../.  
 . /tmp/ccwWCoNY.o -lgcc --as-needed -lgcc_s
--no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-neede 
  d
/opt/gcc431/lib/gcc/i686-pc-linux-gnu/4.3.1/crtend.o /usr/lib/crtn.o
/tmp/ccwWCoNY.o: In function
`CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)':
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexEC1EPS0_[CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)]+0x10): undefined reference to
`operator new[](unsigned int   
)'
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexEC1EPS0_[CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)]+0x50): undefined reference to
`ACE_Thread_Mutex::ACE_Threa   
d_Mutex(char const*, pthread_mutexattr_t*)'
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexEC1EPS0_[CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)]+0x82): undefined reference to
`__cxa_allocate_exception'
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexEC1EPS0_[CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)]+0x9c): undefined reference to
`typeinfo for int'
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexEC1EPS0_[CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)]+0xa4): undefined reference to
`__cxa_throw'
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexEC1EPS0_[CircularBuffer::CircularBuffer(ACE_Thread_Mutex*)]+0xba): undefined reference to
`ACE_Thread_Mutex::~ACE_Thre   
ad_Mutex()'
/tmp/ccwWCoNY.o: In function
`CircularBuffer::~CircularBuffer()':
CircularBufferTest.cpp:(.text._ZN14CircularBufferI16ACE_Thread_MutexED1Ev[CircularBuffer::~CircularBuffer()]+0x10): undefined reference to
`ACE_Thread_Mutex::~ACE_Thread_Mutex()'
/tmp/ccwWCoNY.o: In function `ACE_OS::thread_mutex_lock(pthread_mutex_t*)':
CircularBufferTest.cpp:(.text._ZN6ACE_OS17thread_mutex_lockEP15pthread_mutex_t[ACE_OS::thread_mutex_lo
  
ck(pthread_mutex_t*)]+0xd): undefined reference to
`ACE_OS::mutex_lock(pthread_mutex_t*)'
/tmp/ccwWCoNY.o: In function `ACE_OS::thread_mutex_unlock(pthread_mutex_t*)':
CircularBufferTest.cpp:(.text._ZN6ACE_OS19thread_mutex_unlockEP15pthread_mutex_t[ACE_OS::thread_mutex_
 

[Bug c++/47347] New: "pragma GCC diagnostic ignored" has no effect sometimes

2011-01-18 Thread gcc at dpinol dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47347

   Summary: "pragma GCC diagnostic ignored" has no effect
sometimes
   Product: gcc
   Version: 4.5.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: g...@dpinol.com


The code below produces warning "warning: unused parameter ‘a’
[-Wunused-parameter]" were it shouldn't, since this diagnostic should be
ignored.
If we remove the final line, the warning does not appear, but I understand that
a pragma should not affect previous lines.

#pragma GCC diagnostic ignored "-Wunused-parameter"

#include 

template 
struct KeyValue
{
public:
  virtual ~KeyValue()
  {
  }

  virtual void serialize(int a) const
  {
  }
};

void f()
{
  std::vector< KeyValue  >  values;
}
#pragma GCC diagnostic warning "-Wunused-parameter"


[Bug c++/43308] New: internal compiler error: in simplify_binary_operation_1

2010-03-09 Thread gcc at dpinol dot com
I got this compiling a qt file
../../include/QtGui/private/../../../src/gui/painting/qdrawhelper_mmx_p.h: In
function ‘void comp_func_SourceAtop(uint*, const uint*, int, uint) [with MM =
QMMXIntrinsics, uint = unsigned int]’:
../../include/QtGui/private/../../../src/gui/painting/qdrawhelper_mmx_p.h:540:1:
internal compiler error: in simplify_binary_operation_1, at simplify-rtx.c:3022

I attach .ii. Be aware that the problem can only be reproduce when compiled
both -O2 and -g


-- 
   Summary: internal compiler error: in simplify_binary_operation_1
   Product: gcc
   Version: 4.5.0
Status: UNCONFIRMED
  Severity: major
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at dpinol dot com
 GCC build triplet: i686-gnu-linux
  GCC host triplet: i686-gnu-linux
GCC target triplet: i686-gnu-linux


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



[Bug debug/43308] internal compiler error: in simplify_binary_operation_1

2010-03-09 Thread gcc at dpinol dot com


--- Comment #1 from gcc at dpinol dot com  2010-03-09 18:18 ---
Created an attachment (id=20062)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=20062&action=view)
text

build it with g++ -g -O2 -mmmx qdrawhelper_mmx.ii to reproduce the error
(btw, upgrading a file to bugzilla is a pain!)


-- 


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



[Bug sanitizer/61978] New: implement blacklist for sanitizer

2014-07-31 Thread gcc at dpinol dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61978

Bug ID: 61978
   Summary: implement blacklist for sanitizer
   Product: gcc
   Version: 4.9.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at dpinol dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org

clang has a -fsanitize-blacklist for this

thanks


[Bug sanitizer/61978] implement blacklist for sanitizer

2014-08-01 Thread gcc at dpinol dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61978

--- Comment #3 from Daniel Pinol  ---
I agree with Kostya. 
I get an error within Qt, and I cannot modify its source code. Another option
would be having a flag for not aborting execution when an error is detected (as
in valgrind)

I tried adding the no_sanitize_address attribute to the method which eventually
calls the problematic function, but it did not work.

Is it possible to reopen a ticket until a solution for these kind of problems
is addressed?

thanks

#if defined(__has_feature)
#  if __has_feature(address_sanitizer)
__attribute__((no_sanitize_address))
#  endif
#endif
void triggerLang(ReemWindow &win, config::Language const &lang)



==15711==ERROR: AddressSanitizer: global-buffer-overflow on address 0x09de51cc
at pc 0xb7263661 bp 0xbfd89638 sp 0xbfd8961c
READ of size 21 at 0x09de51cc thread T0
#0 0xb7263660 in __interceptor_memcmp
../../.././libsanitizer/asan/asan_interceptors.cc:325
#1 0xb513b25b (/opt/qtsdk-4.85/lib/libQtCore.so.4+0x1a925b)
#2 0xb513bffa (/opt/qtsdk-4.85/lib/libQtCore.so.4+0x1a9ffa)
#3 0xb513cc7a in QTranslator::translate(char const*, char const*, char
const*) const (/opt/qtsdk-4.85/lib/libQtCore.so.4+0x1aac7a)
#4 0xb513cd13 in QTranslator::translate(char const*, char const*, char
const*, int) const (/opt/qtsdk-4.85/lib/libQtCore.so.4+0x1aad13)
#5 0xb511bc16 in QCoreApplication::translate(char const*, char const*, char
const*, QCoreApplication::Encoding, int)
(/opt/qtsdk-4.85/lib/libQtCore.so.4+0x189c16)
#6 0xb511c0a9 in QCoreApplication::translate(char const*, char const*, char
const*, QCoreApplication::Encoding)
(/opt/qtsdk-4.85/lib/libQtCore.so.4+0x18a0a9)
#7 0x950803f in Ui_VideoWindow::retranslateUi(QWidget*)
/home/dani/svn/robot/gcc491-sanitizer/src/interaction/gui/touchscreen/ReemH/videoWindow/ui_VideoWindow.h:267
#8 0x94f9cea in
pal::gui::VideoWindow::TriggerLanguageChanged(pal::config::Language const&)
/home/dani/svn/robot/sources/src/interaction/gui/touchscreen/ReemH/videoWindow/VideoWindow.cpp:146
#9 0x982afe4 in
pal::gui::ReemWidget::triggerLanguageChanged(pal::config::Language const&)
/home/dani/svn/robot/sources/src/interaction/gui/touchscreen/ReemWidget.cpp:476
#10 0x982b18a in
pal::gui::ReemWidget::triggerLanguageChanged(pal::config::Language const&)
/home/dani/svn/robot/sources/src/interaction/gui/touchscreen/ReemWidget.cpp:511
#11 0x92daab5 in pal::gui::triggerLang(pal::gui::ReemWindow&,
pal::config::Language const&)
/home/dani/svn/robot/sources/src/interaction/gui/touchscreen/ReemH/ReemWindow.cpp:315


[Bug sanitizer/61978] implement blacklist for sanitizer

2014-08-01 Thread gcc at dpinol dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61978

--- Comment #7 from Daniel Pinol  ---
thank you everybody for your great feedback!

@kostya: I provide here the full log. Even removing the #if's, it still aborts.
strict_memcmp=0 worked like a charm. Thanks!

I guess there's no way to just report the errors but not abort execution,
right?


0x09de51cc is located 52 bytes to the left of global variable '*.LC2' from
'/home/dani/svn/robot/sources/src/interaction/gui/touchscreen/ReemH/videoWindow/VideoWindow.cpp'
(0x9de5200) of size 1
  '*.LC2' is ascii string ''
0x09de51cc is located 0 bytes to the right of global variable '*.LC1' from
'/home/dani/svn/robot/sources/src/interaction/gui/touchscreen/ReemH/videoWindow/VideoWindow.cpp'
(0x9de51c0) of size 12
  '*.LC1' is ascii string 'VideoWindow'
SUMMARY: AddressSanitizer: global-buffer-overflow
../../.././libsanitizer/asan/asan_interceptors.cc:325 __interceptor_memcmp
Shadow bytes around the buggy address:
  0x213bc9e0: 04 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x213bc9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x213bca00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x213bca10: 01 f9 f9 f9 f9 f9 f9 f9 01 f9 f9 f9 f9 f9 f9 f9
  0x213bca20: 01 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=>0x213bca30: 00 00 00 00 00 00 00 00 00[04]f9 f9 f9 f9 f9 f9
  0x213bca40: 01 f9 f9 f9 f9 f9 f9 f9 00 00 01 f9 f9 f9 f9 f9
  0x213bca50: 00 00 01 f9 f9 f9 f9 f9 00 07 f9 f9 f9 f9 f9 f9
  0x213bca60: 00 05 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x213bca70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x213bca80: 00 01 f9 f9 f9 f9 f9 f9 00 00 03 f9 f9 f9 f9 f9
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:   00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:   fa
  Heap right redzone:  fb
  Freed heap region:   fd
  Stack left redzone:  f1
  Stack mid redzone:   f2
  Stack right redzone: f3
  Stack partial redzone:   f4
  Stack after return:  f5
  Stack use after scope:   f8
  Global redzone:  f9
  Global init order:   f6
  Poisoned by user:f7
  Contiguous container OOB:fc
  ASan internal:   fe
==19590==ABORTING


[Bug c++/36767] New: Segmentation fault with -fprofile-arcs -O2

2008-07-09 Thread gcc at dpinol dot com
Hi,

The code at the bottom compiled with this line
  gcc -fprofile-arcs -O2  -c kk.cpp
causes this crash
  gcc: Internal error: Segmentation fault (program cc1plus)

It occurs on both:
 * Suse 11.0 with gcc (SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch
revision 135036] (rpms: gcc43-4.3.1_20080507-6.1 and gcc-c++-4.3-39.1)

 * gcc 4.3.1 compiled with default options on Suse 10.2

best regards

#include 


class PathElement {

public:
float a;

~PathElement() {}
};

class PathPlanning {

public:

std::vector v;

PathPlanning();
};
PathPlanning offset2[2];


-- 
   Summary: Segmentation fault with -fprofile-arcs -O2
   Product: gcc
   Version: 4.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at dpinol dot com


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



[Bug c++/36768] New: Segmentation fault with -fprofile-arcs -O2

2008-07-09 Thread gcc at dpinol dot com
Hi,

The code at the bottom compiled with this line
  gcc -fprofile-arcs -O2  -c kk.cpp
causes this crash
  gcc: Internal error: Segmentation fault (program cc1plus)

It occurs on both:
 * Suse 11.0 with gcc (SUSE Linux) 4.3.1 20080507 (prerelease) [gcc-4_3-branch
revision 135036] (rpms: gcc43-4.3.1_20080507-6.1 and gcc-c++-4.3-39.1)

 * gcc 4.3.1 compiled with default options on Suse 10.2

best regards

#include 


class PathElement {

public:
float a;

~PathElement() {}
};

class PathPlanning {

public:

std::vector v;

PathPlanning();
};
PathPlanning offset2[2];


-- 
   Summary: Segmentation fault with -fprofile-arcs -O2
   Product: gcc
   Version: 4.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at dpinol dot com


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



[Bug c++/36833] New: unexpected warning: guard 13936 owner may be used uninitialized in this function

2008-07-15 Thread gcc at dpinol dot com
Hi,

When compiling the code below with 
gcc -c  -O2   -Wall main.cpp -I/opt/ACE_wrappers
, I get the warning 
/opt/ACE_wrappers/ace/Guard_T.inl:24: unexpected warning: guard 13936 owner may
be used uninitialized in this function

The warning refers to a guard's field, where the mutex passed in this line
  ACE_Write_Guard< MUTEX > guard (_mutex);

I've done a thousand tests but I have been unable to reproduce the warning
without using ACE. Even trimming the ACE headers made the warning to go away. 

What convinces me that the problem is in the compiler and not in ACE, or in my
code, is that removing some lines which have nothing to do with the mutex makes
the warning to disappear. Also commenting out the throw at the constructor
disables the warning

If you comment out any of these 3 lines, the warning disappears.
  c_pBufferStart( new int[ 10 ]),
  c_pBufferEnd( c_pBufferStart+10),
  m_pRead( (int*)c_pBufferStart ),

I can see the warning with both ACE 5.5 and latest ACE 5.6.5 available at
ftp://download.dre.vanderbilt.edu/previous_versions/ACE-src-5.6.5.tar.gz (only
9Mb)

I could also cut & paste the .ii file, but it's 38Kb

thanks

#include 
#include 


  template<  class MUTEX = ACE_Thread_Mutex>
  class CircularBuffer
  {
 // Construction/Destruction
  public:
 CircularBuffer(MUTEX *mutex = NULL);

 unsigned long write( );

  protected:
 const int* c_pBufferStart;
 const int* c_pBufferEnd;
 int* m_pRead;
 MUTEX _nullMutex;
 MUTEX &_mutex;
  };


template< class MUTEX >
  CircularBuffer<  MUTEX >::CircularBuffer(MUTEX *mutex):
  c_pBufferStart( new int[ 10 ]),
  c_pBufferEnd( c_pBufferStart+10),
  m_pRead( (int*)c_pBufferStart ),
  _mutex(mutex == NULL ? _nullMutex : *mutex)
{
  if (mutex == NULL) throw "hjhk";
}

template< class MUTEX >
  unsigned long CircularBuffer<  MUTEX >::write( )
{
   ACE_Write_Guard< MUTEX > guard (_mutex);
return 0;
}


  int main()
  {
 CircularBuffer buffer2;
 buffer2.write();
  }


-- 
   Summary: unexpected warning: guard 13936 owner may be used
uninitialized in this function
   Product: gcc
   Version: 4.3.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gcc at dpinol dot com


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



[Bug c++/36833] unexpected warning: guard 13936 owner may be used uninitialized in this function

2008-07-15 Thread gcc at dpinol dot com


--- Comment #1 from gcc at dpinol dot com  2008-07-15 09:11 ---
Created an attachment (id=15910)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15910&action=view)
File generated by -save-temps

I didn't know you could upload files.
I attach file generated by -save-temps so that you don't need ACE to compile my
testcase


-- 


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