This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR libstdc++/19510: Uninitialized variable in someiterators


Gabriel Dos Reis wrote:

Chris Jefferson <caj@cs.york.ac.uk> writes:

| Volker Reichelt wrote:
| | >PR libstdc++/19510 is about a warning that is triggered from within the
| >libstdc++ headers. When compiling the following code snippet with
| >"-Wall -O3" using mainline
| >
| >===============================================
| >#include<vector>
| >#include<list>
| >
| >std::vector<std::list<int>::iterator> v(1);
| >===============================================
| >
| >the following warning is issued:
| >
| >/long_path/stl_construct.h: In function 'void
| >__static_initialization_and_destruction_0(int, int)':
| >/long_path/stl_construct.h:81: warning: 'SR.133' is used uninitialized in this
| >function
| >
| >
| I apologise if this is obvious / stupid, but is this really a bug in
| the class, or in the error message?
| | I get the same error arriving from:
| | #include<vector>
| | struct ptrwrapper {
| int* a;
| ptrwrapper() {}
| };
| | std::vector<ptrwrapper> v(1);



That is an error in the class ptrwrapper. Failing to initialise
ptrwrapper::a results in undefined behaviour when you use it.


But where am I "using" a? How this is this significantly different from the code:

int i=10;
int *a=&ci;
int* b;
a=b;

(or some such code)
which I believe is perfectly valid? (according to 8.3.1/2)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]