[Bug c++/80320] Constructor executed twice for the same static member when using -fno-implicit-templates

2024-03-26 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80320

--- Comment #2 from Andrew Pinski  ---
For not emitting the guard:
#define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)  \
|| DECL_ONE_ONLY (decl) \
|| DECL_WEAK (decl)))


Since the decl is extern, so none of those are true.

But I think it should get that far for this variable.
I have not looked fully in the front-end to understand this code further.

[Bug c++/80320] Constructor executed twice for the same static member when using -fno-implicit-templates

2017-04-05 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80320

Jonathan Wakely  changed:

   What|Removed |Added

   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2017-04-05
 Ever confirmed|0   |1

--- Comment #1 from Jonathan Wakely  ---
(In reply to James Abbatiello from comment #0)
> I don't know exactly what's supposed to happen with -fno-implicit-templates
> and static members.  I initially expected that main.o would not try to
> construct any static members since they were not explicitly instantiated. 
> If that were the case then the static would only be constructed by foo.o and
> things would work correctly.

I think that's what should happen.


> I've tested this on various versions of GCC and it occurs on 4.4.7, 4.9.2,
> 6.3.0 and a copy of 7.0.1 built from trunk so this does not seem like a
> recent regression.

And also 4.3.6