public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42032]  New: Aliasing errors in stl_tree.h
@ 2009-11-13 19:23 craig dot schlenter at gmail dot com
  2009-11-13 19:25 ` [Bug c++/42032] " pinskia at gcc dot gnu dot org
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: craig dot schlenter at gmail dot com @ 2009-11-13 19:23 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2198 bytes --]

I'm seeing the following error:

In function ‘int main()’:
cc1plus: 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:184:
note: initialized from here

I'm unsure of these are legitimate warnings i.e. if stl_tree.h is genuinely
faulty or if it's a false positive from g++. This appears to be similar to
issue 39207.

This problem was originally encountered in chromium (dev.chromium.org) but I
have produced a much reduced test case below. I'm not expecting the reduced
test case to run of course but compilation would be nice :)

Compile with -O2 -Wall

[begin main.cc]

#include <list>
#include <map>

class MyClass {
 public:
  typedef std::list<int> MyList;
  typedef std::map<int, MyList::iterator> MyMap;

  MyClass() {}
  ~MyClass() {}

  void Fail(const int key) {
    MyMap::iterator map_iter = map_.find(key);
    // this doesn't fail
    MyList::iterator list_iter = map_iter->second;
    // this does
    list_.erase(map_iter->second);
  }

  MyList list_;
  MyMap map_;
};


int main(void)
{
  MyClass myclass;

  myclass.Fail(5);

  return 0;
}

[end main.cc]

Please let me know if you need a save-temps version too.

Thank you!

$ gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran --disable-libgcj
--with-tune=generic --with-arch=i586 --build=i386-redhat-linux
Thread model: posix
gcc version 4.4.0 20090310 (Red Hat 4.4.0-0.24) (GCC)


-- 
           Summary: Aliasing errors in stl_tree.h
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: craig dot schlenter at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-09-26 10:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-42032-4@http.gcc.gnu.org/bugzilla/>
2011-09-25 16:04 ` [Bug c++/42032] Aliasing errors in stl_tree.h paolo.carlini at oracle dot com
2011-09-25 16:08 ` evan at chromium dot org
2011-09-26 10:46 ` rguenth at gcc dot gnu.org
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
2009-11-13 19:25 ` [Bug c++/42032] " pinskia at gcc dot gnu dot org
2009-11-13 19:34 ` craig dot schlenter at gmail dot com
2009-11-13 19:49 ` evan at chromium dot org
2009-11-13 19:54 ` rguenth at gcc dot gnu dot org
2009-11-13 20:03 ` rguenth at gcc dot gnu dot org
2009-11-13 20:52 ` paolo dot carlini at oracle dot com
2009-11-16  4:38 ` craig dot schlenter at gmail dot com
2010-05-04 12:06 ` paolo dot carlini at oracle 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).