Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-03 Thread Joseph Lord via swift-evolution
I gave a quick reply to an email later in the chain last night but I think these points are worth addressing. Apologies for the slow response, I wanted to ponder and consider the points rather than rush the response. >> On Dec 31, 2015, at 8:27 PM, Chris Lattner wrote: >> >> On Dec 28, 2015, a

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-02 Thread Arnold via swift-evolution
Sent from my iPhone > On Jan 2, 2016, at 6:35 PM, Dave Abrahams wrote: > > >> On Jan 2, 2016, at 2:57 AM, Arnold wrote: >> >> 'assert' evaluates the condition and aborts only in Odebug builds. >> >> 'precondition' evaluates the condition and aborts also in optimized -0 >> builds. >> >> A

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-02 Thread Arnold via swift-evolution
'assert' evaluates the condition and aborts only in Odebug builds. 'precondition' evaluates the condition and aborts also in optimized -0 builds. As far as I remember the decision was made to give it this semantics to mimic C's assert() function. If an abort is desired in optimized builds one

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-02 Thread Joseph Lord via swift-evolution
> On Jan 2, 2016, at 5:39 PM, Dave Abrahams via swift-evolution > wrote: > > >>> On Dec 31, 2015, at 1:56 PM, Dave Abrahams via swift-evolution >>> wrote: >>> >>> >>> On Dec 31, 2015, at 12:27 PM, Chris Lattner via swift-evolution >>> wrote: >>> >>> On Dec 28, 2015, at 5:48 AM, Joseph L

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-02 Thread Dave Abrahams via swift-evolution
> On Dec 31, 2015, at 1:56 PM, Dave Abrahams via swift-evolution > wrote: > >> >> On Dec 31, 2015, at 12:27 PM, Chris Lattner via swift-evolution >> wrote: >> >> On Dec 28, 2015, at 5:48 AM, Joseph Lord via swift-evolution >> wrote: >>> The documented behaviour of assert and assertionFail

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-02 Thread Dave Abrahams via swift-evolution
> On Jan 2, 2016, at 2:57 AM, Arnold wrote: > > 'assert' evaluates the condition and aborts only in Odebug builds. > > 'precondition' evaluates the condition and aborts also in optimized -0 builds. > > As far as I remember the decision was made to give it this semantics to > mimic C's assert

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-02 Thread Kevin Ballard via swift-evolution
On Fri, Jan 1, 2016, at 11:58 PM, Kevin Ballard wrote: > On Fri, Jan 1, 2016, at 11:25 PM, Chris Lattner via swift-evolution wrote: > > > On Dec 31, 2015, at 1:56 PM, Dave Abrahams wrote: > > >>> 2) Adding asserts to code should not make the code more dangerous > > >>> whatever the build. Assumin

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-01 Thread Kevin Ballard via swift-evolution
On Fri, Jan 1, 2016, at 11:25 PM, Chris Lattner via swift-evolution wrote: > > On Dec 31, 2015, at 1:56 PM, Dave Abrahams wrote: > >>> 2) Adding asserts to code should not make the code more dangerous > >>> whatever the build. Assuming the truth of the assert may lead to runtime > >>> safety che

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-01 Thread Dave Abrahams via swift-evolution
> On Jan 1, 2016, at 11:25 PM, Chris Lattner wrote: > >> On Dec 31, 2015, at 1:56 PM, Dave Abrahams wrote: 2) Adding asserts to code should not make the code more dangerous whatever the build. Assuming the truth of the assert may lead to runtime safety checks being skipped and

Re: [swift-evolution] Asserts should not cause undefined behaviour

2016-01-01 Thread Chris Lattner via swift-evolution
> On Dec 31, 2015, at 1:56 PM, Dave Abrahams wrote: >>> 2) Adding asserts to code should not make the code more dangerous whatever >>> the build. Assuming the truth of the assert may lead to runtime safety >>> checks being skipped and undefined behaviour when a no-op would be a safe >>> behavio

Re: [swift-evolution] Asserts should not cause undefined behaviour

2015-12-31 Thread Dave Abrahams via swift-evolution
> On Dec 31, 2015, at 12:27 PM, Chris Lattner via swift-evolution > wrote: > > On Dec 28, 2015, at 5:48 AM, Joseph Lord via swift-evolution > wrote: >> The documented behaviour of assert and assertionFailure in "disable safety >> checks" builds (still documented as -Ounchecked) is that the c

Re: [swift-evolution] Asserts should not cause undefined behaviour

2015-12-31 Thread Chris Lattner via swift-evolution
On Dec 28, 2015, at 5:48 AM, Joseph Lord via swift-evolution wrote: > The documented behaviour of assert and assertionFailure in "disable safety > checks" builds (still documented as -Ounchecked) is that the compiler "may > assume that it would evaluate to true" or in the assertionFailure case

[swift-evolution] Asserts should not cause undefined behaviour

2015-12-28 Thread Joseph Lord via swift-evolution
I propose that assert and assertionFailure should be no-ops (with branch hints) in unchecked builds as they are in normal release builds rather than resulting in undefined behaviour in the failure condition. I would like to kick off a discussion of this. I found the proposal template useful fo