public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/49106] New: static variable is optimized away even though it is referenced by a nested constructor
@ 2011-05-22 11:15 burnus at gcc dot gnu.org
  2011-05-22 11:56 ` [Bug middle-end/49106] " rguenth at gcc dot gnu.org
  2021-08-10 21:37 ` pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-05-22 11:15 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: static variable is optimized away even though it is
                    referenced by a nested constructor
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


In the following program, the function "test" is optimized way as the node is
not marked as needed. Thus, the static variable "a" is removed - even though it
is referenced in the nested constructor "_const_func".

Result: Link error:
/tmp/ccaIjMKk.o: In function `_const_func.1591':
test.c:(.text+0x6): undefined reference to `a.1589'

Expected: The local static should not be optimized way, i.e. the nested
function lowering should properly update the cgraph ipa reference list.


Side remark: For my purpose (coarray initialization in gfortran) it would be
best if in such a case both the function and the constructor could be optimized
away. Thus, if there would be some method on tree-level to tell this cgraph ...


main ()
{
  void test (void)
  {
    static int a;
    void __attribute__((constructor))
    _const_func(void)
    {
      a = 7;
    }
  }
  return 0;
}


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

* [Bug middle-end/49106] static variable is optimized away even though it is referenced by a nested constructor
  2011-05-22 11:15 [Bug middle-end/49106] New: static variable is optimized away even though it is referenced by a nested constructor burnus at gcc dot gnu.org
@ 2011-05-22 11:56 ` rguenth at gcc dot gnu.org
  2021-08-10 21:37 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-05-22 11:56 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011.05.22 11:17:27
                 CC|                            |hubicka at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-05-22 11:17:27 UTC ---
Confirmed.


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

* [Bug middle-end/49106] static variable is optimized away even though it is referenced by a nested constructor
  2011-05-22 11:15 [Bug middle-end/49106] New: static variable is optimized away even though it is referenced by a nested constructor burnus at gcc dot gnu.org
  2011-05-22 11:56 ` [Bug middle-end/49106] " rguenth at gcc dot gnu.org
@ 2021-08-10 21:37 ` pinskia at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-10 21:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49106

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |7.0
             Status|NEW                         |RESOLVED
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=77555
         Resolution|---                         |FIXED

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Fixed in GCC 7+.

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

end of thread, other threads:[~2021-08-10 21:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-22 11:15 [Bug middle-end/49106] New: static variable is optimized away even though it is referenced by a nested constructor burnus at gcc dot gnu.org
2011-05-22 11:56 ` [Bug middle-end/49106] " rguenth at gcc dot gnu.org
2021-08-10 21:37 ` pinskia at gcc dot gnu.org

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).