From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4725 invoked by alias); 16 Nov 2009 04:38:10 -0000 Received: (qmail 4660 invoked by uid 48); 16 Nov 2009 04:37:57 -0000 Date: Mon, 16 Nov 2009 04:38:00 -0000 Message-ID: <20091116043757.4659.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/42032] Aliasing errors in stl_tree.h In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "craig dot schlenter at gmail dot com" 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 X-SW-Source: 2009-11/txt/msg01276.txt.bz2 ------- Comment #7 from craig dot schlenter at gmail dot com 2009-11-16 04:37 ------- (In reply to comment #3) > I brought this up on the Google-internal C list. They reduced it further: > > $ cat main.cc > #include > > int main(void) > { > typedef std::map MyMap2; > MyMap2 map2_; > MyMap2::iterator map_iter2 = map2_.find(5); > return *map_iter2->second; > } > $ g++ -O3 -Wall -c main.cc > main.cc: In function 'int main()': > main.cc:8: warning: dereferencing pointer '' does break > strict-aliasing rules > /opt/local/include/gcc44/c++/bits/stl_tree.h:179: note: initialized from here Hironori Bono spotted btw. that if the key for the map is changed from an int to a std::string, then the aliasing warning disappears: #include #include int main(void) { typedef std::map MyMap2; MyMap2 map2_; MyMap2::iterator map_iter2 = map2_.find("hello"); return *map_iter2->second; } This is rather strange and confusing. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032