Bug 38937 - [4.4 Regression] dereferencing pointer '<anonymous>' does break strict-aliasing
Summary: [4.4 Regression] dereferencing pointer '<anonymous>' does break strict-aliasing
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.4.0
: P3 normal
Target Milestone: 4.4.0
Assignee: Richard Biener
URL:
Keywords: diagnostic, wrong-code
Depends on:
Blocks:
 
Reported: 2009-01-22 19:15 UTC by Benjamin Kosnik
Modified: 2009-01-31 17:53 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2009-01-30 22:20:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Benjamin Kosnik 2009-01-22 19:15:03 UTC
On s390x, there are some libstdc++ failures that are not present on other platforms. 

Here is a representative test run:
http://gcc.gnu.org/ml/gcc-testresults/2009-01/msg02102.html

And here is the failure analysis:
http://gcc.gnu.org/ml/libstdc++/2009-01/msg00109.html

The following fails appear to be spurious and only occur on s390x. At first I thought this might be because of the extra flags "-fstack-protector --param=ssp-buffer-size=4" but compiling the problem testcases on x86_64/linux with the same flag doesn't show an error. So, I don't know what's up.

The same testcases (when present) pass without error on 4.3.2.

FAIL: 21_strings/basic_string/element_access/wchar_t/empty.cc
FAIL: 23_containers/list/modifiers/1.cc
FAIL: 23_containers/list/modifiers/3.cc
FAIL: 23_containers/list/modifiers/insert/25288.cc

The usual error looks like:

warning: dereferencing pointer '<anonymous>' does break strict-aliasing
rules

which is incomprehensible.
Comment 1 Richard Biener 2009-01-22 22:44:50 UTC
This is likely because of different inlining decisions which is possibly because
of different insn costs which depend on MOVE_MAX_PIECES and MOVE_RATIO.

The warning itself hints at either an alias problem in the testcase or the
library or at a problem with points-to analysis.
Comment 2 Richard Biener 2009-01-25 18:05:20 UTC
Does the following patch fix this?

http://gcc.gnu.org/ml/gcc-patches/2009-01/msg01245.html

If so please mark this bug as a dup of PR38503.
Comment 3 Paolo Carlini 2009-01-30 16:57:41 UTC
In the meanwhile the patch for PR38503 has been installed and unfortunately I have to report that this issue seems indeed different, eg, this testcase is still not fixed on x86_64-linux:

#include <string>
#include <list>

class A;

class B {
public:
    void foo(A&);
    std::string s;
};

class A {
public:
    A& qaz() {
        l.push_back( new A() );
        return *l.back();
    }
    std::list<A*> l;
};

void bar()
{
    A a;
    B b;
    b.foo(a.qaz());
}
Comment 4 Richard Biener 2009-01-30 22:20:24 UTC
Confirmed on i?86 as well, even with 4.3 headers:

./cc1plus -quiet -O2 -Wall /tmp/t.ii 
t.C: In function 'void bar()':
t.C:16: warning: dereferencing pointer '<anonymous>' does break strict-aliasing rules
/usr/include/c++/4.3/bits/stl_list.h:132: note: initialized from here

I will have a looksee.
Comment 5 Richard Biener 2009-01-30 22:51:49 UTC
For

  hook (D.15560_20, &a.l.D.14002._M_impl._M_node);

we somehow compute the wrong ESCAPED solution.

ESCAPED = { NULL ANYTHING ESCAPED NONLOCAL a b D.15681 }

this is missing a.32+32.

Bah, it turns out I again have this fixed on the alias-improvements branch.
So - I have a patch.
Comment 6 Richard Biener 2009-01-31 10:25:51 UTC
Subject: Bug 38937

Author: rguenth
Date: Sat Jan 31 10:25:41 2009
New Revision: 143819

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143819
Log:
2009-01-30  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/38937
	* tree-ssa-structalias.c (do_sd_constraint): Do not shortcut
	computing the transitive closure.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-ssa-structalias.c

Comment 7 Richard Biener 2009-01-31 10:25:54 UTC
Fixed.
Comment 8 H.J. Lu 2009-01-31 17:49:37 UTC
Don't we need to add a testcase in comment #3?
Comment 9 Richard Biener 2009-01-31 17:53:03 UTC
Feel free to reduce one.  I think using libstdc++ in g++.dg is not possible?
Comment 10 Richard Biener 2009-02-02 10:39:23 UTC
Subject: Bug 38937

Author: rguenth
Date: Mon Feb  2 10:39:12 2009
New Revision: 143864

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=143864
Log:
2009-02-02  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/38937
	* g++.dg/warn/Wstrict-aliasing-bogus-escape.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/warn/Wstrict-aliasing-bogus-escape.C
Modified:
    trunk/gcc/testsuite/ChangeLog