Boost logo

Boost :

Subject: [boost] [array] Invalid data: accessing 'elems'
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2010-08-02 12:29:40


Hi,

I compile a small test program using Visual C++ 10.0 (Visual Studio 2010
Premium) with static code analysis turned on (option /analyze):

#include <boost/array.hpp>
int main()
{
      typedef int T; // short, char, etc.
      boost::array<T, 2> x;
      T a = x[0];
}

and whichever integer type I use for T, the analyser throws
similar reports every time:

1>------ Build started: Project: boost_array_test, Configuration: Debug
Win32 ------
1> boost_array_test.cpp
1>g:\workshop\boost\boost_test\array\boost_array_test.cpp(5): warning
C4189: 'a' : local variable is initialized but not referenced
1>g:\dev\boost\_svn\trunk\boost\array.hpp(111): warning C6385: Invalid
data: accessing 'elems', the readable size is '8' bytes, but '12' bytes
might be read: Lines: 110, 111
1> G:\dev\boost\_svn\trunk\boost/array.hpp(109) : while
compiling class template member function 'int
&boost::array<T,N>::operator [](boost::array<T,N>::size_type)'
1> with
1> [
1> T=int,
1> N=0x2
1> ]
1> boost_array_test.cpp(4) : see reference to class template
instantiation 'boost::array<T,N>' being compiled
1> with
1> [
1> T=int,
1> N=0x2
1> ]
1> boost_array_test.vcxproj ->
G:\workshop\boost\boost_test\array\Debug\boost_array_test.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Shall I report a ticket?

No warnings are reported for the std::array provided
with Visaul C++ 10.0.

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk