[llvm-bugs] [Bug 47956] std::map:operator= does assignment on the underlying value type, dereferencing references!

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Oct 23 15:33:50 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47956

Greg Alexander <greg at dignus.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|NEW                         |RESOLVED

--- Comment #2 from Greg Alexander <greg at dignus.com> ---
(sorry for the false start on this comment, I don't know how to use this
version of bugzilla, I guess)

The more I think about this, the more I think I owe you guys an apology for
wasting your time on this.  Obviously, you'll say, "you can't use references in
containers."

There are some map operations which are not going to generally be possible with
references, like assignment using map[key] = value.  But there are other map
operations such as map.emplace(key, value) and map1=map2 that can work with
references, depending on the library implementation.  I've done a survey of a
few STL implementations (including old SGI STLport) and LLVM libc++ is the only
one that won't allow map assignment with a const reference.  That doesn't mean
libc++ is wrong, but it puts me in this bind where I have to tell the customer
his code that worked for decades is wrong.

The underlying trouble is the unsolvable central contradiction of C++.  The
language itself provides no way to do better.  Template classes will always be
in this vague state of "partly works sometimes", inviting abuse.

This is not a problem I expect you guys will be able to fix, so I'm marking it
WONTFIX.  Thanks for your time!

(sorry for the false start on this comment, I don't know how to use this
version of bugzilla, I guess)

The more I think about this, the more I think I owe you guys an apology for
wasting your time on this.  Obviously, you'll say, "you can't use references in
containers."

There are some map operations which are not going to generally be possible with
references, like assignment using map[key] = value.  But there are other map
operations such as map.emplace(key, value) and map1=map2 that can work with
references, depending on the library implementation.  I've done a survey of a
few STL implementations (including old SGI STLport) and LLVM libc++ is the only
one that won't allow map assignment with a const reference.  That doesn't mean
libc++ is wrong, but it puts me in this bind where I have to tell the customer
his code that worked for decades is wrong.

The underlying trouble is the unsolvable central contradiction of C++.  The
language itself provides no way to do better.  Template classes will always be
in this vague state of "partly works sometimes", inviting abuse.

This is not a problem I expect you guys will be able to fix, so I'm marking it
WONTFIX.  Thanks for your time!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201023/8bd27739/attachment-0001.html>


More information about the llvm-bugs mailing list