[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

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

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||wrong-code
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=80320
  Known to fail||

--- Comment #14 from Andrew Pinski  ---
I think this and PR 80320 both have the same underlying issue.

[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2009-01-27 Thread bkoz at gcc dot gnu dot org


--- Comment #13 from bkoz at gcc dot gnu dot org  2009-01-27 17:26 ---
*** Bug 25956 has been marked as a duplicate of this bug. ***


-- 

bkoz at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||jkp at kirkconsulting dot co
   ||dot uk


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-20 Thread pinskia at gcc dot gnu dot org


--- Comment #12 from pinskia at gcc dot gnu dot org  2006-06-21 05:05 
---
-fno-weak worked in 3.0.4 and below, though I don't know if it was really
working so I am not marking this as a regression.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

  Known to fail||3.2.3 3.4.0 4.0.0 4.1.0
   ||4.2.0
   Target Milestone|4.0.4   |---


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-20 Thread pinskia at gcc dot gnu dot org


--- Comment #11 from pinskia at gcc dot gnu dot org  2006-06-21 04:50 
---
Actually I take that back, it is also a problem with targets that don't have
weak symbols too.
On x86_64-linux-gnu with the additional flag of -fno-weak:
pc64:~> g++ test.cc test1.cc -fno-weak
pc64:~> ./a.out
new: mString has value 0x502010
new: mString has value 0x502030
delete: mString has value 0x502030
delete: mString has value 0x502030
*** glibc detected *** double free or corruption (fasttop): 0x00502030
***
Abort

So the new part of the test should be just shrunk back to testing
DECL_EXPLICIT_INSTANTIATION instead of the other parts too.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 GCC target triplet|*-darwin|non weak
   Target Milestone|--- |4.0.4


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-19 Thread hhinnant at apple dot com


--- Comment #10 from hhinnant at apple dot com  2006-06-19 18:11 ---
It turns out this still isn't quite right.  Looks like we need:

#define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl) \
|| DECL_ONE_ONLY (decl) \
|| DECL_WEAK (decl) \
||
(TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
   && DECL_LANG_SPECIFIC
(decl) \
   &&
(DECL_EXPLICIT_INSTANTIATION (decl) \
   || 
DECL_TEMPLATE_SPECIALIZATION (decl)

The former solution was dereferencing a null pointer.


-- 


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread hhinnant at apple dot com


--- Comment #9 from hhinnant at apple dot com  2006-06-13 22:02 ---
(In reply to comment #8)

Thanks.  That not only makes sense to me now, but it passes the test. :-)


-- 


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread pinskia at physics dot uc dot edu


--- Comment #8 from pinskia at physics dot uc dot edu  2006-06-13 21:47 
---
Subject: Re:  lack of guard variables for explicitly instantiated template
static data

> 
> 
> 
> --- Comment #7 from hhinnant at apple dot com  2006-06-13 21:41 ---
> (In reply to comment #6)
> > Subject: Re:  lack of guard variables for explicitly instantiated template
> > static data
> > 
> > > #define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)
> > >   \
> > > || DECL_ONE_ONLY 
> > > (decl) \
> > > || DECL_WEAK (decl) \
> > > ||
> > > (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
> > >   || (! DECL_EXPLICIT_INSTANTIATION (decl) \
> > >   && ! DECL_TEMPLATE_SPECIALIZATION (decl)
> > > 
> > > ?
> > 
> > The latter.
> 
> Thanks.  But this doesn't pass the test case on darwin.  I'm not familiar
> enough with the C++ FE to understand TARGET_WEAK_NOT_IN_ARCHIVE_TOC.  Could 
> you
> double check the above.  The "!" in front of DECL_EXPLICIT_INSTANTIATION looks
> especially suspicious to me.

You want the opposite of that like:
(TARGET_WEAK_NOT_IN_ARCHIVE_TOC && (DECL_EXPLICIT_INSTANTIATION (decl) ||
DECL_TEMPLATE_SPECIALIZATION (decl)))

I was quoting the case when DECL_WEAK would be set on the decl.
TARGET_WEAK_NOT_IN_ARCHIVE_TOC is only defined to 1 for darwin.  

-- Pinski


-- 


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



Re: [Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread Andrew Pinski
> 
> 
> 
> --- Comment #7 from hhinnant at apple dot com  2006-06-13 21:41 ---
> (In reply to comment #6)
> > Subject: Re:  lack of guard variables for explicitly instantiated template
> > static data
> > 
> > > #define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)
> > >   \
> > > || DECL_ONE_ONLY 
> > > (decl) \
> > > || DECL_WEAK (decl) \
> > > ||
> > > (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
> > >   || (! DECL_EXPLICIT_INSTANTIATION (decl) \
> > >   && ! DECL_TEMPLATE_SPECIALIZATION (decl)
> > > 
> > > ?
> > 
> > The latter.
> 
> Thanks.  But this doesn't pass the test case on darwin.  I'm not familiar
> enough with the C++ FE to understand TARGET_WEAK_NOT_IN_ARCHIVE_TOC.  Could 
> you
> double check the above.  The "!" in front of DECL_EXPLICIT_INSTANTIATION looks
> especially suspicious to me.

You want the opposite of that like:
(TARGET_WEAK_NOT_IN_ARCHIVE_TOC && (DECL_EXPLICIT_INSTANTIATION (decl) || 
DECL_TEMPLATE_SPECIALIZATION (decl)))

I was quoting the case when DECL_WEAK would be set on the decl.
TARGET_WEAK_NOT_IN_ARCHIVE_TOC is only defined to 1 for darwin.  

-- Pinski


[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread hhinnant at apple dot com


--- Comment #7 from hhinnant at apple dot com  2006-06-13 21:41 ---
(In reply to comment #6)
> Subject: Re:  lack of guard variables for explicitly instantiated template
> static data
> 
> > #define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)  
> > \
> > || DECL_ONE_ONLY (decl) 
> > \
> > || DECL_WEAK (decl) \
> > ||
> > (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
> >   || (! DECL_EXPLICIT_INSTANTIATION (decl) \
> >   && ! DECL_TEMPLATE_SPECIALIZATION (decl)
> > 
> > ?
> 
> The latter.

Thanks.  But this doesn't pass the test case on darwin.  I'm not familiar
enough with the C++ FE to understand TARGET_WEAK_NOT_IN_ARCHIVE_TOC.  Could you
double check the above.  The "!" in front of DECL_EXPLICIT_INSTANTIATION looks
especially suspicious to me.


-- 


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread pinskia at physics dot uc dot edu


--- Comment #6 from pinskia at physics dot uc dot edu  2006-06-13 21:24 
---
Subject: Re:  lack of guard variables for explicitly instantiated template
static data

> #define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)  \
> || DECL_ONE_ONLY (decl) \
> || DECL_WEAK (decl) \
> ||
> (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
>   || (! DECL_EXPLICIT_INSTANTIATION (decl) \
>   && ! DECL_TEMPLATE_SPECIALIZATION (decl)
> 
> ?

The latter.

-- Pinski


-- 


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



Re: [Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread Andrew Pinski
> #define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)  \
> || DECL_ONE_ONLY (decl) \
> || DECL_WEAK (decl) \
> ||
> (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
>   || (! DECL_EXPLICIT_INSTANTIATION (decl) \
>   && ! DECL_TEMPLATE_SPECIALIZATION (decl)
> 
> ?

The latter.

-- Pinski


[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread hhinnant at apple dot com


--- Comment #5 from hhinnant at apple dot com  2006-06-13 21:23 ---
(In reply to comment #4)
>For Darwin we do not want explicit instantiations to be
>linkonce.  */
> 
> 
> This is why this testcase fails on darwin.
> We should instead of just adding DECL_EXPLICIT_INSTANTIATION, check
> TARGET_WEAK_NOT_IN_ARCHIVE_TOC.
> 
> (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC
>   || (! DECL_EXPLICIT_INSTANTIATION (decl)
>   && ! DECL_TEMPLATE_SPECIALIZATION (decl)))
> 
> This is a darwin only issue.

I'm having trouble deciding exactly what you mean.  Is this what you mean:

#define NEEDS_GUARD_P(decl) (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
  || (! DECL_EXPLICIT_INSTANTIATION (decl) \
  && ! DECL_TEMPLATE_SPECIALIZATION (decl)))

Or do you mean:

#define NEEDS_GUARD_P(decl) (TREE_PUBLIC (decl) && (DECL_COMMON (decl)  \
|| DECL_ONE_ONLY (decl) \
|| DECL_WEAK (decl) \
||
(!TARGET_WEAK_NOT_IN_ARCHIVE_TOC \
  || (! DECL_EXPLICIT_INSTANTIATION (decl) \
  && ! DECL_TEMPLATE_SPECIALIZATION (decl)

?


-- 


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread pinskia at gcc dot gnu dot org


--- Comment #4 from pinskia at gcc dot gnu dot org  2006-06-13 19:37 ---

   For Darwin we do not want explicit instantiations to be
   linkonce.  */


This is why this testcase fails on darwin.
We should instead of just adding DECL_EXPLICIT_INSTANTIATION, check
TARGET_WEAK_NOT_IN_ARCHIVE_TOC.

(!TARGET_WEAK_NOT_IN_ARCHIVE_TOC
  || (! DECL_EXPLICIT_INSTANTIATION (decl)
  && ! DECL_TEMPLATE_SPECIALIZATION (decl)))

This is a darwin only issue.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Last reconfirmed|-00-00 00:00:00 |2006-06-13 19:37:25
   date||


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread pinskia at gcc dot gnu dot org


--- Comment #3 from pinskia at gcc dot gnu dot org  2006-06-13 19:18 ---
   || DECL_ONE_ONLY (decl) || DECL_WEAK (decl) \

Actually those looks should include what is defined for Darwin.


-- 

pinskia at gcc dot gnu dot org changed:

   What|Removed |Added

   GCC host triplet|darwin ppc  |
 GCC target triplet||*-darwin


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread pinskia at gcc dot gnu dot org


--- Comment #2 from pinskia at gcc dot gnu dot org  2006-06-13 19:15 ---
(In reply to comment #1)
> This works on x86-linux-gnu on the mainline.

Oh and in 3.3.3.


-- 


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



[Bug c++/28017] lack of guard variables for explicitly instantiated template static data

2006-06-13 Thread pinskia at gcc dot gnu dot org


--- Comment #1 from pinskia at gcc dot gnu dot org  2006-06-13 19:14 ---
This works on x86-linux-gnu on the mainline.


-- 


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