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

            Bug ID: 109405
           Summary: Should class final decoration result in larger
                    unique_ptr with deleter ?
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at hazlewoods dot net
  Target Milestone: ---

Whilst making an attempt to ensure some `std::unique_ptr<>` types had size
`sizeof(intptr_t)`, I was using empty `struct` deleters.
I habitually tapped `final` on a struct, and was surprised to see my
`static_assert`s fire.

Maybe this is a consequence of the push for devirtualization optimization, but
hopefully this can be confirmed.

```
#include <iostream>
#include <memory>

int main()
{
    struct S { void operator()() {} };
    struct SF final { void operator()() {} };
    std::cout << "S : " << sizeof(S) << std::endl;
    std::cout << "SF: " << sizeof(SF) << std::endl;

    using SP = std::unique_ptr<int, S>;
    using SFP = std::unique_ptr<int, SF>;
    std::cout << "SP : " << sizeof(SP) << std::endl;
    std::cout << "SFP: " << sizeof(SFP) << std::endl;
}
```


https://godbolt.org/z/Gfz4W5sP1

Reply via email to