|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:41:21 -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=P0vOvF4MDP8WKao5SluI6NWOCCMvE8x/hyFLjzlDdq0=; b=viFJDE9CNSJibgrbHRmcKrfzWJyYgSmpTJrA1wfnjL5qcN7FkwIjbaZwHUiUFHfNEv bS7bgkEEv20a3RcW5uX9woQ0tJ7L7H6PHd97hrKMOSWvmiuXTXR5gSoRVGvl0N6LgYgd g0v0yS9EJZMMP7SbHCcX8nTMWr6jT9bMtorAi0fy4nF0iaa17vLjPGICxDPbzguaQnld btsAWV74m1FOd3c6KzbFW5SPXEGMKgbJfl/jAqY7yIljZlTPaOtfTq0Dtg5LvaX2G2N+ Hw1wcqc7803sJngC2by/QerWG3+hGP37pvnfDbP9Es7xQHj3SCjS3P8QaxzyZ4UhdkPK wytA==
Sure, from the compiler authors perspective, the current behavior of signed integers in C++ is ideal. Since overflow is undefined behavior, for them it is optimization opportunities. They can do all sorts of optimizations thanks to being able to assume that overflow does not happen.
But from the perspective of software developers, the undefined behavior in signed overflow is danger.
That leads to one of the strongest arguments in favor of unsigned: at least, that has well-defined (wrapping) overflow behavior. That might be 'broken', but it isn't nearly as dangerous as the undefined behavior of signed overflow!
The point I want to make is: compiler users (us, here) and compiler authors have inherently different, sometimes conflicting, agenda.
Again --- not advocating for unsigned indices! Just saying it's not clear-cut either way.