Bug 40658 - spurious warning "array subscript is below array bounds"
Summary: spurious warning "array subscript is below array bounds"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.3
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-06 09:22 UTC by Axel Naumann
Modified: 2009-07-06 11:21 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: -m32
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Naumann 2009-07-06 09:22:25 UTC
Compiling the following code snippet with "g++ -m32 -S -Wall -O2 t.cc" on a 64bit machine issues a warning

t.cc: In static member function 'static void NewDelFunctionsT<T>::deleteArray_T(void*) [with T = EcalTPGLut]':
t.cc:12: warning: array subscript is below array bounds

This does not happen with 4.4.

t.cc:
class EcalTPGLut {
 public:
   ~EcalTPGLut() ;

 private:
  unsigned int lut_[1024];
};

template <class T>
struct NewDelFunctionsT {
   static void
   deleteArray_T(void* p) { delete[] (T*) p; }
};

typedef void (*DelArrFunc_t)(void*);

DelArrFunc_t method_newdel_98() {
   return NewDelFunctionsT< ::EcalTPGLut >::deleteArray_T;
}
Comment 1 Mikael Pettersson 2009-07-06 09:32:34 UTC
Ditto here on powerpc64-unknown-linux-gnu. -m32 gives the warning, -m64 does not.
Comment 2 Paolo Carlini 2009-07-06 09:57:46 UTC
I'm afraid it's highly unlikely that this will be fixed in 4_3-branch... To the best of my knowledge, fixing it involved a few rather invasive patches and the branch is close to its end of life...
Comment 3 Axel Naumann 2009-07-06 10:59:45 UTC
OK, I didn't know that the branch is closed, nor that it involves extensive changes. Sorry it took me so long to find this! I can of course use #pragma GCC diagnostic ignored "-Warray-bounds" if needed.
Comment 4 Manuel López-Ibáñez 2009-07-06 11:21:00 UTC
This is FIXED in GCC 4.4. There may be a 4.3.4 release but this is not a regression and nobody seems interested in investigating whether it can be fixed with a minimal patch. So I am closing it as FIXED.

If you can reproduce it with GCC 4.5, please reopen.