public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95950] New: Call to pseudo-destructor does not end the lifetime until C++20
@ 2020-06-28 20:27 kutdanila at yandex dot ru
  2020-06-28 20:38 ` [Bug c++/95950] " kutdanila at yandex dot ru
  2020-06-28 21:02 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: kutdanila at yandex dot ru @ 2020-06-28 20:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95950

            Bug ID: 95950
           Summary: Call to pseudo-destructor does not end the lifetime
                    until C++20
           Product: gcc
           Version: 9.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kutdanila at yandex dot ru
  Target Milestone: ---

#include <optional>

int main() {
  std::optional<int> t = 2;
  using T = std::optional<int>;
  t.~T();
  return t.has_value();
}

g++ test.cpp -O1 -o test


This code should not return 0 until C++20, see
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0593r4.html and
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0593r4.html#c5-c-and-iso-c-2017-diffcpp17

In that case, std::optional<int> has a trivial destructor and should have no
effect

The regression started somewhere in the 9th version of gcc in any optimized
builds (O1-O3, with O0 still ok)

Yet, static_assert works fine

#include <optional>

int main() {
  constexpr std::optional<int> t = 2;
  using T = std::optional<int>;
  t.~T();
  static_assert(t.has_value());
}

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

* [Bug c++/95950] Call to pseudo-destructor does not end the lifetime until C++20
  2020-06-28 20:27 [Bug c++/95950] New: Call to pseudo-destructor does not end the lifetime until C++20 kutdanila at yandex dot ru
@ 2020-06-28 20:38 ` kutdanila at yandex dot ru
  2020-06-28 21:02 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: kutdanila at yandex dot ru @ 2020-06-28 20:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95950

Danila Kutenin <kutdanila at yandex dot ru> changed:

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

--- Comment #1 from Danila Kutenin <kutdanila at yandex dot ru> ---
I reread the standard, call to destructor for class types ends the lifetime, so
this behaviour is valid

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

* [Bug c++/95950] Call to pseudo-destructor does not end the lifetime until C++20
  2020-06-28 20:27 [Bug c++/95950] New: Call to pseudo-destructor does not end the lifetime until C++20 kutdanila at yandex dot ru
  2020-06-28 20:38 ` [Bug c++/95950] " kutdanila at yandex dot ru
@ 2020-06-28 21:02 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2020-06-28 21:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95950

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Right, t.~T() is only a pseudo-destructor for a scalar type. For a class type,
it's a destructor.

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

end of thread, other threads:[~2020-06-28 21:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-28 20:27 [Bug c++/95950] New: Call to pseudo-destructor does not end the lifetime until C++20 kutdanila at yandex dot ru
2020-06-28 20:38 ` [Bug c++/95950] " kutdanila at yandex dot ru
2020-06-28 21:02 ` redi 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).