public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity
@ 2005-07-07 20:29 yuri at tsoft dot com
  2005-07-07 20:39 ` [Bug c++/22355] " pinskia at gcc dot gnu dot org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: yuri at tsoft dot com @ 2005-07-07 20:29 UTC (permalink / raw)
  To: gcc-bugs

Following code (f()) if compiled with -fno-exceptions should
produce only one initialization boolean for all local
static variables, not one per variable. This is since
they always initialized together provided there are no exceptions.

If exceptions are allowed then it should be driven by
the flag in constructors saying if they allow exceptions or not.

Yuri

---------------------------
struct C {
  C();
  int get();
};


int f() {
  static C i;
  static C j;
  return (i.get() + j.get());
}

-- 
           Summary: Multiple local static variables initialization: missed
                    optimization opportunity
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: yuri at tsoft dot com
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug c++/22355] Multiple local static variables initialization: missed optimization opportunity
  2005-07-07 20:29 [Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity yuri at tsoft dot com
@ 2005-07-07 20:39 ` pinskia at gcc dot gnu dot org
  2005-07-07 20:52 ` giovannibajo at libero dot it
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-07-07 20:39 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-07 20:39 -------
Say we call f() again before finish initializing i. then we call the get statement, it just undefined?

-- 


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


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

* [Bug c++/22355] Multiple local static variables initialization: missed optimization opportunity
  2005-07-07 20:29 [Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity yuri at tsoft dot com
  2005-07-07 20:39 ` [Bug c++/22355] " pinskia at gcc dot gnu dot org
@ 2005-07-07 20:52 ` giovannibajo at libero dot it
  2005-07-07 21:21 ` yuri at Magma-DA dot COM
  2005-07-07 22:14 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: giovannibajo at libero dot it @ 2005-07-07 20:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-07-07 20:52 -------
I think Andres is right: what if C's constructor calls f() (only the first time 
it is invoked)?

I believe this bug is invalid.

-- 


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


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

* [Bug c++/22355] Multiple local static variables initialization: missed optimization opportunity
  2005-07-07 20:29 [Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity yuri at tsoft dot com
  2005-07-07 20:39 ` [Bug c++/22355] " pinskia at gcc dot gnu dot org
  2005-07-07 20:52 ` giovannibajo at libero dot it
@ 2005-07-07 21:21 ` yuri at Magma-DA dot COM
  2005-07-07 22:14 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: yuri at Magma-DA dot COM @ 2005-07-07 21:21 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From yuri at Magma-DA dot COM  2005-07-07 21:21 -------
Subject: Re:  Multiple local static variables initialization:
 missed optimization opportunity

I agree, this situation is fuzzy and bug is probably invalid.
But there are actually local static initializations that are to blame.

Why should these be checked/initialized on entry into the function, not 
globally?
Any particular benefit of this ?
I think it would have been way cleaner if initializations were done 
globally when code is loaded.

Yuri


pinskia at gcc dot gnu dot org wrote:

>------- Additional Comments From pinskia at gcc dot gnu dot org  2005-07-07 20:39 -------
>Say we call f() again before finish initializing i. then we call the get statement, it just undefined?
>
>  
>



-- 


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


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

* [Bug c++/22355] Multiple local static variables initialization: missed optimization opportunity
  2005-07-07 20:29 [Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity yuri at tsoft dot com
                   ` (2 preceding siblings ...)
  2005-07-07 21:21 ` yuri at Magma-DA dot COM
@ 2005-07-07 22:14 ` bangerth at dealii dot org
  3 siblings, 0 replies; 5+ messages in thread
From: bangerth at dealii dot org @ 2005-07-07 22:14 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2005-07-07 22:14 -------
That's just what the standard says: these variables are initialized when 
execution first passes their location of declaration. 
 
I guess this PR is indeed invalid, so I close it. 
 
W. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2005-07-07 22:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-07 20:29 [Bug c++/22355] New: Multiple local static variables initialization: missed optimization opportunity yuri at tsoft dot com
2005-07-07 20:39 ` [Bug c++/22355] " pinskia at gcc dot gnu dot org
2005-07-07 20:52 ` giovannibajo at libero dot it
2005-07-07 21:21 ` yuri at Magma-DA dot COM
2005-07-07 22:14 ` bangerth at dealii dot 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).