#include <string>
#include <map>
const std::string &usage ();
void
foo ()
{
std::map < std::string, int >best_scores;
const std::map < std::string, int >::const_iterator current_best =
best_scores.find (usage ());
if (0 < current_best->second) best_scores[usage ()] = 0;
}
yields:
LC_ALL=C g++ -S -O2 -Wall ai.C
ai.C: In function 'void foo()':
ai.C:11: warning: dereferencing pointer '<anonymous>' does break
strict-aliasing rules
/usr/lib/gcc/i386-redhat-linux/4.4.0/../../../../include/c++/4.4.0/bits/stl_tree.h:259:
note: initialized from here
I'll attach another testcase which doesn't include any headers and triggers 3
warnings.
--
Summary: [4.4 Regression] Strict aliasing warnings in libstdc++
headers
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jakub at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39207