[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

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

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=96645

--- Comment #8 from Andrew Pinski  ---
Seems related to PR 96645 (and CWG2335).

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2024-03-05 Thread benni.buch at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

--- Comment #7 from Benjamin Buch  ---
Sorry wrong number; Bug 114076

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2024-03-05 Thread benni.buch at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

Benjamin Buch  changed:

   What|Removed |Added

 CC||benni.buch at gmail dot com

--- Comment #6 from Benjamin Buch  ---
I think this is a sub-case of Bug 104850

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2024-02-23 Thread de34 at live dot cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

Jiang An  changed:

   What|Removed |Added

 CC||de34 at live dot cn

--- Comment #5 from Jiang An  ---
Clang started to accept this since Clang 16. https://godbolt.org/z/c6vGzTP48

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2022-03-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

--- Comment #4 from Andrew Pinski  ---
Interesting if I put the definition of the class A::B at the end of the file,
the code works 

I wonder if this is because of some ABI issue where A::A as a base class is
created 

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2022-03-09 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

--- Comment #3 from Andrew Pinski  ---
clang and ICC also reject this for the same reason as GCC.
MSVC on the other hand accepts this.

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2022-03-09 Thread kirshamir at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

--- Comment #2 from Amir Kirsh  ---
// adding the required include to the example

#include  // for nullptr_t

template
struct uptr {
uptr(nullptr_t) {}
~uptr() {
delete (new T);
}
};

class A
{
public:
  A();
  ~A();
private:
  class B;
  uptr m_b = nullptr; // the dtor of uptr tries to be instantiated here
};

https://wandbox.org/permlink/rJeeB3Sliey6tGzR

If we change the initialization of:
uptr m_b = nullptr; 
To:
uptr m_b {nullptr}; 

Relevant SO post:
https://stackoverflow.com/questions/71397495/why-does-default-member-initializer-request-instantiation-of-unique-ptr-destru/71402270#71402270

[Bug c++/104850] Instantiating a destructor for a template class too early, before the calling destructor is seen - rejects valid code

2022-03-09 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104850

Richard Biener  changed:

   What|Removed |Added

   Last reconfirmed||2022-03-09
   Keywords||rejects-valid
 Ever confirmed|0   |1
 Status|UNCONFIRMED |WAITING

--- Comment #1 from Richard Biener  ---
I get

t.ii:3:10: error: unknown type name 'nullptr_t'
uptr(nullptr_t) {}
 ^

please fix your example.