public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61973] New: __thread and deleted destructor
@ 2014-07-31 7:27 nyh at math dot technion.ac.il
2015-03-27 17:09 ` [Bug c++/61973] " paolo.carlini at oracle dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: nyh at math dot technion.ac.il @ 2014-07-31 7:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61973
Bug ID: 61973
Summary: __thread and deleted destructor
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nyh at math dot technion.ac.il
Hi, right now "__thread" insists that the given type has a trivial destructor.
There is unfortunately no way to silence this error, even when I deliberately
want this (e.g., I know I'll call ~T() explicitly in another way).
I figured out a way (see below) to *delete* a type's destructor, using a union
(see below). However, __thread only accepts a trivial destructor, not a deleted
destructor. Is there a reason __thread cannot accept a type with a deleted
destructor?
Bonus points to anyone who can figure out how I can use __thread (not
thread_local) on a type with a non-trivial destructor even in existing gcc ;-)
The code to "delete" a type's destructor:
template <class T>
class mask_destructor {
private:
union {
alignas(T) char bytes[sizeof(T)];
T obj;
};
public:
T& get() const { return obj; }
// preserve T's constexpr constructor
constexpr mask_destructor() : obj() { }
mask_destructor(const mask_destructor &other) : obj(other.obj) { }
mask_destructor &operator=(const mask_destructor &other){
obj = other.obj;
return *this;
}
// Note no destructor defined. The compile implicitly deletes it
// because of the anonymous union above.
};
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/61973] __thread and deleted destructor
2014-07-31 7:27 [Bug c++/61973] New: __thread and deleted destructor nyh at math dot technion.ac.il
@ 2015-03-27 17:09 ` paolo.carlini at oracle dot com
2015-03-27 17:26 ` redi at gcc dot gnu.org
2021-09-27 11:33 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: paolo.carlini at oracle dot com @ 2015-03-27 17:09 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61973
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2015-03-27
Ever confirmed|0 |1
--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Please provide a self-contained snippet showing the issue.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/61973] __thread and deleted destructor
2014-07-31 7:27 [Bug c++/61973] New: __thread and deleted destructor nyh at math dot technion.ac.il
2015-03-27 17:09 ` [Bug c++/61973] " paolo.carlini at oracle dot com
@ 2015-03-27 17:26 ` redi at gcc dot gnu.org
2021-09-27 11:33 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2015-03-27 17:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61973
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Nadav Har'El from comment #0)
> Bonus points to anyone who can figure out how I can use __thread (not
> thread_local) on a type with a non-trivial destructor even in existing gcc
> ;-)
__thread std::aligned_storage<T>::type buf;
__thread T* obj = [&]{ return ::new(&buf) T(blah blah); }();
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/61973] __thread and deleted destructor
2014-07-31 7:27 [Bug c++/61973] New: __thread and deleted destructor nyh at math dot technion.ac.il
2015-03-27 17:09 ` [Bug c++/61973] " paolo.carlini at oracle dot com
2015-03-27 17:26 ` redi at gcc dot gnu.org
@ 2021-09-27 11:33 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-27 11:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61973
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |WONTFIX
Status|WAITING |RESOLVED
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
thread_local has become more wildly used than __thread. GCC does a decent job
even of not emitting TLS initializers and such. So closing as won't fix.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-27 11:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-31 7:27 [Bug c++/61973] New: __thread and deleted destructor nyh at math dot technion.ac.il
2015-03-27 17:09 ` [Bug c++/61973] " paolo.carlini at oracle dot com
2015-03-27 17:26 ` redi at gcc dot gnu.org
2021-09-27 11:33 ` 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).