public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) @ 2010-08-05 22:00 eric_moyer at yahoo dot com 2010-08-05 22:02 ` [Bug libstdc++/45202] " eric_moyer at yahoo dot com ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: eric_moyer at yahoo dot com @ 2010-08-05 22:00 UTC (permalink / raw) To: gcc-bugs [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: Type: text/plain, Size: 2085 bytes --] The following code (as small as I can get but I'm not sure its minimal) #include <set> struct X{ unsigned a; X(){} bool operator<(const X& i)const { return a < i.a; } }; struct R{ std::set<X> getSet() const{ std::set<X> result; result.insert(X()); return result; } }; void bug(){ for(unsigned x = 0; x < 2; ++x){ std::set<X> pts = R().getSet(); } } Produces the following warnings: bug-check2.cpp: In function void bug(): bug-check2.cpp:6: warning: dereferencing pointer __x.22 does break strict-aliasing rules /usr/include/c++/4.4/bits/stl_tree.h:525: note: initialized from here bug-check2.cpp:6: warning: dereferencing pointer __x.22 does break strict-aliasing rules /usr/include/c++/4.4/bits/stl_tree.h:525: note: initialized from here When compiled with: g++ -Wall -O3 -c bug-check2.cpp With version 4.4.1 on Ubuntu 9.10 (Sorry for the old version, it would take hours to recompile g++ and I already have put several into reducing the test-case.) I will be attaching the g++ verbose output, the preprocessed source, and the original source. Unusual symptoms: 1. Making getSet static or a global function removes the warning. 2. Reducing the number of loop iterations below 2 reduces or removes the warning. 3. Removing the constructor for X removes one of the warnings. 4. Changing X::operator< to return a constant value removes the warning 5. Changing X::operator< to {return a < b; } where b is a global variable removes the warning 6. Removing the result.insert(X()) line removes the warnings 7. Making result a global variable removes the warnings. -- Summary: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libstdc++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: eric_moyer at yahoo dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45202 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/45202] Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) 2010-08-05 22:00 [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) eric_moyer at yahoo dot com @ 2010-08-05 22:02 ` eric_moyer at yahoo dot com 2010-08-05 22:03 ` eric_moyer at yahoo dot com ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: eric_moyer at yahoo dot com @ 2010-08-05 22:02 UTC (permalink / raw) To: gcc-bugs ------- Comment #1 from eric_moyer at yahoo dot com 2010-08-05 22:02 ------- Created an attachment (id=21415) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21415&action=view) Test case: original source -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45202 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/45202] Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) 2010-08-05 22:00 [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) eric_moyer at yahoo dot com 2010-08-05 22:02 ` [Bug libstdc++/45202] " eric_moyer at yahoo dot com @ 2010-08-05 22:03 ` eric_moyer at yahoo dot com 2010-08-05 22:05 ` eric_moyer at yahoo dot com ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: eric_moyer at yahoo dot com @ 2010-08-05 22:03 UTC (permalink / raw) To: gcc-bugs ------- Comment #2 from eric_moyer at yahoo dot com 2010-08-05 22:03 ------- Created an attachment (id=21416) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21416&action=view) Test case: preprocessed source -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45202 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/45202] Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) 2010-08-05 22:00 [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) eric_moyer at yahoo dot com 2010-08-05 22:02 ` [Bug libstdc++/45202] " eric_moyer at yahoo dot com 2010-08-05 22:03 ` eric_moyer at yahoo dot com @ 2010-08-05 22:05 ` eric_moyer at yahoo dot com 2010-08-05 22:18 ` eric_moyer at yahoo dot com 2010-08-06 6:54 ` paolo dot carlini at oracle dot com 4 siblings, 0 replies; 6+ messages in thread From: eric_moyer at yahoo dot com @ 2010-08-05 22:05 UTC (permalink / raw) To: gcc-bugs ------- Comment #3 from eric_moyer at yahoo dot com 2010-08-05 22:04 ------- Created an attachment (id=21417) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21417&action=view) Test case: output of g++ 4.4.1-ubutntu9 with -v switch -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45202 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/45202] Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) 2010-08-05 22:00 [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) eric_moyer at yahoo dot com ` (2 preceding siblings ...) 2010-08-05 22:05 ` eric_moyer at yahoo dot com @ 2010-08-05 22:18 ` eric_moyer at yahoo dot com 2010-08-06 6:54 ` paolo dot carlini at oracle dot com 4 siblings, 0 replies; 6+ messages in thread From: eric_moyer at yahoo dot com @ 2010-08-05 22:18 UTC (permalink / raw) To: gcc-bugs ------- Comment #4 from eric_moyer at yahoo dot com 2010-08-05 22:18 ------- This is not a duplicate of bug# 39390 because my copy of g++ compiles the test case for that bug without complaint. It may be related to 42032 since that does not compile correctly but (1) the error messages are different; (2) the errors are for different lines of the stl_tree file; and (3) that bug relates to a map rather than a set -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45202 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug libstdc++/45202] Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) 2010-08-05 22:00 [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) eric_moyer at yahoo dot com ` (3 preceding siblings ...) 2010-08-05 22:18 ` eric_moyer at yahoo dot com @ 2010-08-06 6:54 ` paolo dot carlini at oracle dot com 4 siblings, 0 replies; 6+ messages in thread From: paolo dot carlini at oracle dot com @ 2010-08-06 6:54 UTC (permalink / raw) To: gcc-bugs ------- Comment #5 from paolo dot carlini at oracle dot com 2010-08-06 06:53 ------- *** This bug has been marked as a duplicate of 42032 *** -- paolo dot carlini at oracle dot com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |DUPLICATE http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45202 ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-08-06 6:54 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2010-08-05 22:00 [Bug libstdc++/45202] New: Strict aliasing warning in stl_tree (returning a copy of a set from a member function in a loop) eric_moyer at yahoo dot com 2010-08-05 22:02 ` [Bug libstdc++/45202] " eric_moyer at yahoo dot com 2010-08-05 22:03 ` eric_moyer at yahoo dot com 2010-08-05 22:05 ` eric_moyer at yahoo dot com 2010-08-05 22:18 ` eric_moyer at yahoo dot com 2010-08-06 6:54 ` paolo dot carlini at oracle dot com
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).