* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
@ 2009-11-13 19:25 ` pinskia at gcc dot gnu dot org
2009-11-13 19:34 ` craig dot schlenter at gmail dot com
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2009-11-13 19:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2009-11-13 19:25 -------
Might be related to PR 39390.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
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
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: craig dot schlenter at gmail dot com @ 2009-11-13 19:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from craig dot schlenter at gmail dot com 2009-11-13 19:34 -------
(In reply to comment #1)
> Might be related to PR 39390.
Would it be possible for someone to test the code from the description section
with trunk please .. if error messages were removed, the problem should be gone
:) I unfortunately don't have easy access to a more modern gcc than 4.4.0 to
test with.
Thank you.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
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
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: evan at chromium dot org @ 2009-11-13 19:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from evan at chromium dot org 2009-11-13 19:49 -------
I brought this up on the Google-internal C list. They reduced it further:
$ cat main.cc
#include <map>
int main(void)
{
typedef std::map<int, char*> 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 '<anonymous>' does break
strict-aliasing rules
/opt/local/include/gcc44/c++/bits/stl_tree.h:179: note: initialized from here
$ g++ -v
Using built-in specs.
Target: i386-apple-darwin9
Configured with: ../gcc-4.4.1/configure --prefix=/opt/local
--build=i386-apple-darwin9
--enable-languages=c,c++,objc,obj-c++,java,fortran
--libdir=/opt/local/lib/gcc44 --includedir=/opt/local/include/gcc44
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--with-local-prefix=/opt/local --with-system-zlib --disable-nls
--program-suffix=-mp-4.4
--with-gxx-include-dir=/opt/local/include/gcc44/c++/
--with-gmp=/opt/local --with-mpfr=/opt/local
Thread model: posix
gcc version 4.4.1 (GCC)
--
evan at chromium dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |evan at chromium dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
` (2 preceding siblings ...)
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
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-13 19:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from rguenth at gcc dot gnu dot org 2009-11-13 19:54 -------
It may be related to PR41316, I suspected that the library might contain
similar patterns in other containers besides forward_list.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
` (3 preceding siblings ...)
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
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-11-13 20:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2009-11-13 20:02 -------
There are definitely a lot of casts like
static_cast<_Link_type>(_M_node)
in stl_list.h. If _M_node is ever not a rb_tree_node but only a
rb_tree_node_base
(which probably is the case again for the head of the tree) then this is an
alias violation.
Note that 4.5 will no longer warn for this because I removed the warning code
as it wasn't aware of the concept of C++ dynamic types and thus lead to many
false positives. There is no replacement for it, so you'll need to do code
review to catch all cases.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
` (4 preceding siblings ...)
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
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-11-13 20:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from paolo dot carlini at oracle dot com 2009-11-13 20:51 -------
Note that, as far as I have been told by Richard, the warning itself doesn't
point to an actual miscompilation in 4.4, because (PRE, etc.) aren't strong
enough. Thus, first people should double check that, and in case we could
backport to 4.4. the warning suppression bits (in any case, that warnings are
emitted from system headers is a bug, per se).
Then, as regards mainline, we should, again, check whether actual
miscompilations are taking place, I'm not aware of any. At the time of PR41316,
I went quickly through the code and didn't find any problematic series of up
and down casts outside (the still very experimental, I'm working on it while we
are speaking) forward_list.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
` (5 preceding siblings ...)
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
8 siblings, 0 replies; 12+ messages in thread
From: craig dot schlenter at gmail dot com @ 2009-11-16 4:38 UTC (permalink / raw)
To: gcc-bugs
------- 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 <map>
>
> int main(void)
> {
> typedef std::map<int, char*> 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 '<anonymous>' 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 <map>
#include <string>
int main(void)
{
typedef std::map<std::string, char*> 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
` (6 preceding siblings ...)
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
8 siblings, 0 replies; 12+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-05-04 12:06 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from paolo dot carlini at oracle dot com 2010-05-04 12:05 -------
*** Bug 43978 has been marked as a duplicate of this bug. ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |musiphil at bawi dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/42032] Aliasing errors in stl_tree.h
2009-11-13 19:23 [Bug c++/42032] New: " craig dot schlenter at gmail dot com
` (7 preceding siblings ...)
2010-05-04 12:06 ` paolo dot carlini at oracle dot com
@ 2010-08-06 6:54 ` paolo dot carlini at oracle dot com
8 siblings, 0 replies; 12+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-08-06 6:54 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from paolo dot carlini at oracle dot com 2010-08-06 06:53 -------
*** Bug 45202 has been marked as a duplicate of this bug. ***
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |eric_moyer at yahoo dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42032
^ permalink raw reply [flat|nested] 12+ messages in thread