Re: [PATCH] PR libstdc++/91788 improve codegen for std::variant::index()

2019-09-24 Thread Jonathan Wakely
On 24/09/19 11:24 +0200, Marc Glisse wrote: On Tue, 24 Sep 2019, Jonathan Wakely wrote: On 24/09/19 09:57 +0100, Jonathan Wakely wrote: On 23/09/19 19:39 +0200, Marc Glisse wrote: On Mon, 23 Sep 2019, Jonathan Wakely wrote: If __index_type is a smaller type than size_t, then the result of s

Re: [PATCH] PR libstdc++/91788 improve codegen for std::variant::index()

2019-09-24 Thread Marc Glisse
On Tue, 24 Sep 2019, Jonathan Wakely wrote: On 24/09/19 09:57 +0100, Jonathan Wakely wrote: On 23/09/19 19:39 +0200, Marc Glisse wrote: On Mon, 23 Sep 2019, Jonathan Wakely wrote: If __index_type is a smaller type than size_t, then the result of size_t(__index_type(-1)) is not equal to size_

Re: [PATCH] PR libstdc++/91788 improve codegen for std::variant::index()

2019-09-24 Thread Jonathan Wakely
On 24/09/19 09:57 +0100, Jonathan Wakely wrote: On 23/09/19 19:39 +0200, Marc Glisse wrote: On Mon, 23 Sep 2019, Jonathan Wakely wrote: If __index_type is a smaller type than size_t, then the result of size_t(__index_type(-1)) is not equal to size_t(-1), but to an incorrect value such as size_

Re: [PATCH] PR libstdc++/91788 improve codegen for std::variant::index()

2019-09-24 Thread Jonathan Wakely
On 23/09/19 19:39 +0200, Marc Glisse wrote: On Mon, 23 Sep 2019, Jonathan Wakely wrote: If __index_type is a smaller type than size_t, then the result of size_t(__index_type(-1)) is not equal to size_t(-1), but to an incorrect value such as size_t(255) or size_t(65535). The old implementation o

Re: [PATCH] PR libstdc++/91788 improve codegen for std::variant::index()

2019-09-23 Thread Marc Glisse
On Mon, 23 Sep 2019, Jonathan Wakely wrote: If __index_type is a smaller type than size_t, then the result of size_t(__index_type(-1)) is not equal to size_t(-1), but to an incorrect value such as size_t(255) or size_t(65535). The old implementation of variant::index() uses (size_t(__index_type(

[PATCH] PR libstdc++/91788 improve codegen for std::variant::index()

2019-09-23 Thread Jonathan Wakely
If __index_type is a smaller type than size_t, then the result of size_t(__index_type(-1)) is not equal to size_t(-1), but to an incorrect value such as size_t(255) or size_t(65535). The old implementation of variant::index() uses (size_t(__index_type(_M_index + 1)) - 1) which is always correct, b