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

--- Comment #5 from Halalaluyafail3 <luigighiron at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> Do you have an actual use case for this, or are you just reporting it
> because there's divergence between implementations?
> 
> I raised it with the standards committee and everybody agrees that we should
> not support this, so I'm creating a new library issue for it.

I have no use case for this, I only found this when looking at the edge cases
of unique_ptr. If you're looking to make this invalid there is another edge
case that I think should also be made invalid:

#include<memory>
#include<iostream>
int main(){
    struct deleter{
        using pointer=float*;
        void operator()(pointer)const{}
    };
    float f=42;
    std::unique_ptr<const int,deleter>u(&f);
    std::cout<<*u<<'\n';
}

The restrictions on unique_ptr don't disallow cases where pointer is unrelated
to the element_type which allows awkward cases like this.

Reply via email to