Bug 60895 - [4.8 Regression] error: address taken, but ADDRESSABLE bit not set
Summary: [4.8 Regression] error: address taken, but ADDRESSABLE bit not set
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 5.0
: P2 normal
Target Milestone: 4.8.3
Assignee: Richard Biener
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2014-04-19 14:03 UTC by Marc Glisse
Modified: 2014-05-05 13:49 UTC (History)
1 user (show)

See Also:
Host:
Target: x86_64-unknown-linux-gnu
Build:
Known to work: 4.10.0, 4.8.3, 4.9.1
Known to fail: 4.8.2, 4.9.0
Last reconfirmed: 2014-04-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Glisse 2014-04-19 14:03:46 UTC
Compiling with g++ grr.ii -c -O

struct C {
  double elems[3];
};
C fn1() {
  double *f;
  C a;
  f = a.elems;
  for (int b; b;) {
    *f = 0;
    ++f;
  }
  return a;
}

struct J {
  C c;
  J() : c(fn1()) {}
};
void fn2() { J(); }


grr.ii: In function 'void fn2()':
grr.ii:19:6: error: address taken, but ADDRESSABLE bit not set
 void fn2() { J(); }
      ^
PHI argument
&D.2276.c.elems;
for PHI node
f_4 = PHI <&D.2276.c.elems(2), f_5(3)>
grr.ii:19:6: internal compiler error: verify_ssa failed
0xf92ebf verify_ssa(bool)
	/data/repos/gcc/trunk/gcc/tree-ssa.c:1096
0xc97869 execute_function_todo
	/data/repos/gcc/trunk/gcc/passes.c:1784
0xc96b38 do_per_function
	/data/repos/gcc/trunk/gcc/passes.c:1504
0xc97983 execute_todo
	/data/repos/gcc/trunk/gcc/passes.c:1817
0xc97eb1 execute_one_ipa_transform_pass
	/data/repos/gcc/trunk/gcc/passes.c:2006
0xc97fb0 execute_all_ipa_transforms()
	/data/repos/gcc/trunk/gcc/passes.c:2037
0x96eae1 expand_function
	/data/repos/gcc/trunk/gcc/cgraphunit.c:1767
0x96f0fe expand_all_functions
	/data/repos/gcc/trunk/gcc/cgraphunit.c:1908
0x96faca compile()
	/data/repos/gcc/trunk/gcc/cgraphunit.c:2252
0x96fc43 finalize_compilation_unit()
	/data/repos/gcc/trunk/gcc/cgraphunit.c:2329
0x6f2294 cp_write_global_declarations()
	/data/repos/gcc/trunk/gcc/cp/decl2.c:4619

This compiles with gcc-4.8. It is reduced from a real program that does not have uninitialized variables.
Comment 1 Jakub Jelinek 2014-04-22 07:48:55 UTC
Started with r193157, but when the testcase is changed into:
struct C
{
  double elems[3];
};

C
foo ()
{
  C a;
  double *f = a.elems;
  int b;
  for (; b;)
    {
      *f = 0;
      ++f;
    }
  return a;
}

struct J
{
  C c;
  __attribute__((always_inline)) J () : c (foo ()) {}
};

void
bar ()
{
  J ();
}

it starts with -O at r192946.  Both of these changes just change inliner's decision, so I guess the bug has been latent before that.
Comment 2 Richard Biener 2014-04-22 08:55:29 UTC
I'll have a look.
Comment 3 Richard Biener 2014-04-22 12:03:14 UTC
We copy TREE_ADDRESSABLE improperly in declare_return_variable with
return_slot not being a decl.  I have a patch.
Comment 4 Richard Biener 2014-04-23 08:27:32 UTC
Author: rguenth
Date: Wed Apr 23 08:27:00 2014
New Revision: 209675

URL: http://gcc.gnu.org/viewcvs?rev=209675&root=gcc&view=rev
Log:
2014-04-23  Richard Biener  <rguenther@suse.de>

	PR middle-end/60895
	* tree-inline.c (declare_return_variable): Use mark_addressable.

	* g++.dg/torture/pr60895.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/torture/pr60895.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c
Comment 5 Richard Biener 2014-04-23 08:28:08 UTC
Author: rguenth
Date: Wed Apr 23 08:27:37 2014
New Revision: 209676

URL: http://gcc.gnu.org/viewcvs?rev=209676&root=gcc&view=rev
Log:
2014-04-23  Richard Biener  <rguenther@suse.de>

	PR middle-end/60895
	* tree-inline.c (declare_return_variable): Use mark_addressable.

	* g++.dg/torture/pr60895.C: New testcase.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/g++.dg/torture/pr60895.C
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-inline.c
Comment 6 Richard Biener 2014-05-05 13:49:14 UTC
Author: rguenth
Date: Mon May  5 13:48:42 2014
New Revision: 210070

URL: http://gcc.gnu.org/viewcvs?rev=210070&root=gcc&view=rev
Log:
2014-05-05  Richard Biener  <rguenther@suse.de>

	Backport from mainline
	2014-04-23  Richard Biener  <rguenther@suse.de>

	PR middle-end/60895
	* tree-inline.c (declare_return_variable): Use mark_addressable.

	* g++.dg/torture/pr60895.C: New testcase.

	2014-04-07  Richard Biener  <rguenther@suse.de>

	PR middle-end/60750
	* tree-ssa-operands.c (maybe_add_call_vops): Also add VDEFs
	for noreturn calls.
	* tree-cfgcleanup.c (fixup_noreturn_call): Do not remove VDEFs.

	* g++.dg/torture/pr60750.C: New testcase.
	* gcc.dg/tree-ssa/20040517-1.c: Adjust.

	2014-04-14  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/59817
	PR tree-optimization/60453
	* graphite-scop-detection.c (graphite_can_represent_scev): Complete
	recursion to catch all CHRECs in the scalar evolution and restrict
	the predicate for the remains appropriately.

	* gfortran.dg/graphite/pr59817.f: New testcase.
	* gcc.dg/graphite/pr59817-1.c: Likewise.
	* gcc.dg/graphite/pr59817-2.c: Likewise.

	2014-04-17  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/60836
	* tree-vect-loop.c (vect_create_epilog_for_reduction): Force
	initial PHI args to be gimple values.

	* g++.dg/vect/pr60836.cc: New testcase.

Added:
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/torture/pr60750.C
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/torture/pr60895.C
    branches/gcc-4_8-branch/gcc/testsuite/g++.dg/vect/pr60836.cc
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/graphite/pr59817-1.c
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/graphite/pr59817-2.c
    branches/gcc-4_8-branch/gcc/testsuite/gfortran.dg/graphite/pr59817.f
Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/graphite-scop-detection.c
    branches/gcc-4_8-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/tree-ssa/20040517-1.c
    branches/gcc-4_8-branch/gcc/tree-cfgcleanup.c
    branches/gcc-4_8-branch/gcc/tree-inline.c
    branches/gcc-4_8-branch/gcc/tree-ssa-operands.c
    branches/gcc-4_8-branch/gcc/tree-vect-loop.c
Comment 7 Richard Biener 2014-05-05 13:49:44 UTC
Fixed.