|Re: [eigen] Signed or unsigned indexing|
[ Thread Index |
| More lists.tuxfamily.org/eigen Archives
- To: eigen <eigen@xxxxxxxxxxxxxxxxxxx>
- Subject: Re: [eigen] Signed or unsigned indexing
- From: Benoit Jacob <jacob.benoit.1@xxxxxxxxx>
- Date: Fri, 20 Jan 2017 13:59:53 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=CxswyPQOa8H6jK1EetrMn5g0wfM7biQ1MVM8W21l4ik=; b=RCoypny1iZVnWUMlXEaZVUwAkd9kUvWVmvnn+MBTkWt0//ADvoMp6jHOWcC3Egt/7b ij8vaI9A7ApyKfiaRD+e1RdHOhQhbGUcHEgp4SCYSKWeofAQ8IdEPaizxB/MEbYXyO5E HXQMAQKxKxslO1wLUjjgoUuzcPuet96UGJm8l/NNc/lZtbx6WsrFYPbG9DmM9ScEPXBK yuY2kA+iBuJIWiNzb/LWq1XC5beq7iujqJQy2P8/Otldlk408QMKAG3lxIN44dpiXYfE iExn46dkfETbTHI8+JBct289XAq+WW38CSHcxr+shtjHDTrPTeDWbTpdumPxD5w6E7jv ZBkA==
a couple of notes:
- i dont believe there is any chance at all of Eigen changing this now -- at least I had been writing in this thread assuming only idle discussion. That would be a very intrusive breaking change to make at this point.
- i do agree with the argument that unsigned makes decrementing loop error-prone at 0. It is the same argument that was made on this mailing list many years ago and motivated the choice of signed indices. We are in violent agreement! :-) I just wanted to point out how it's not clear-cut as both signednesses come with strengths and weaknesses.
The C++ committee theoretically could acknowledge that 2's complement has won and make signed overflow well-defined behavior (as wrapping); if they did that, that would remove one of the main issues with signed and arguably that would start to make it look like a no-brained. But compiler authors wouldn't like that, because it would take away the optimization opportunities.