From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31941 invoked by alias); 31 Jul 2014 01:12:56 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 31787 invoked by uid 48); 31 Jul 2014 01:12:52 -0000 From: "kaijun at seed dot net.tw" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/61971] array subscript is above array bounds [-Werror=array-bounds] Date: Thu, 31 Jul 2014 01:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: kaijun at seed dot net.tw X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-07/txt/msg02020.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61971 --- Comment #1 from kaijun --- $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/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 --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.2-20140120/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux Thread model: posix gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) ======================================================================== $ make -f Makefile2 make -f mytest2.mak all g++ -c -pipe -D_LITTLE_ENDIAN_BYTE_ORDER_ -DLINUX -D_NOT_SOLARIS8 -DSYSTEM_TYPE=10 -ansi -Wno-deprecated -m64 -DUSE_MSG -DDEBUG_SQLITE -DLINUX -DRMM_UNIX -DRUM_UNIX -DRMM_UNIX -DOS_LINUX -D_THREAD_SAFE -D_REENTRANT -Werror -W -Wall -Wpointer-arith -Wcast-align -Wshadow -Wno-long-long -Wstrict-aliasing=0 -Wformat=2 -Wno-deprecated -g -O2 -I/opt/IBM/llm/include -o obj/mytest2.o mytest2.cpp mytest2.cpp: In member function 'void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = ProdBook; _Alloc = std::allocator; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator >; typename std::_Vector_base<_Tp, _Alloc>::pointer = ProdBook*]': mytest2.cpp:32:7: error: array subscript is above array bounds [-Werror=array-bounds] class ProdBook { ^ mytest2.cpp:32:7: error: array subscript is above array bounds [-Werror=array-bounds] cc1plus: all warnings being treated as errors make[1]: *** [obj/mytest2.o] Error 1 make: *** [all] Error 2 ========================================================================= //mytest2.cpp #include #include #include #include #include class CPriceLst; class DPriceLst; class DDPriceLst; class ProdBook; class PriceLst { public: virtual ~PriceLst(); }; class DPriceLst : public PriceLst { public: }; class DDPriceLst : public DPriceLst { public: }; class ProdBook { public: PriceLst m_bs_pr[2]; DPriceLst m_bs_d_pr[2]; // derived order lst DDPriceLst m_bs_dd_pr[2]; // 2nd derived lst ProdBook(); }; class OrderBook { public: std::vector m_prod; }; int main() { void *ptr=NULL; ProdBook prod; ((OrderBook*)ptr)->m_prod.push_back(prod); return 0; } ~