Re: Overflows in Phobos

2016-07-31 Thread Jonathan M Davis via Digitalmars-d
On Sunday, July 31, 2016 21:45:25 Cauterite via Digitalmars-d wrote: > On Saturday, 30 July 2016 at 00:55:11 UTC, Charles Hixson wrote: > > FWIW, in that case I always use > > assert (false, "..."); > > I try to never use integers for booleans. But this may well be > > a common usage. > > I

Re: Overflows in Phobos

2016-07-31 Thread Cauterite via Digitalmars-d
On Saturday, 30 July 2016 at 00:55:11 UTC, Charles Hixson wrote: FWIW, in that case I always use assert (false, "..."); I try to never use integers for booleans. But this may well be a common usage. I suspect `assert(0)` is really `assert(constexpr>)`, so you should be fine. Both styles are

Re: Overflows in Phobos

2016-07-29 Thread Charles Hixson via Digitalmars-d
On 07/26/2016 07:36 AM, ketmar via Digitalmars-d wrote: On Tuesday, 26 July 2016 at 14:28:48 UTC, Timon Gehr wrote: "The expression assert(0) is a special case; it signifies that it is unreachable code. [...] The optimization and code generation phases of compilation may assume that it is

Re: Overflows in Phobos

2016-07-28 Thread qznc via Digitalmars-d
On Thursday, 28 July 2016 at 00:17:16 UTC, Walter Bright wrote: On 7/27/2016 3:47 PM, qznc wrote: On Wednesday, 27 July 2016 at 07:59:54 UTC, Walter Bright wrote: "The expression assert(0) is a special case; it signifies code that should be unreachable. If it is reached at runtime, either

Re: Overflows in Phobos

2016-07-28 Thread BLM768 via Digitalmars-d
On Wednesday, 27 July 2016 at 07:59:54 UTC, Walter Bright wrote: "The expression assert(0) is a special case; it signifies code that should be unreachable. If it is reached at runtime, either AssertError is thrown or execution is terminated in an implementation-defined manner. Any code after

Re: Overflows in Phobos

2016-07-27 Thread Walter Bright via Digitalmars-d
On 7/27/2016 3:47 PM, qznc wrote: On Wednesday, 27 July 2016 at 07:59:54 UTC, Walter Bright wrote: "The expression assert(0) is a special case; it signifies code that should be unreachable. If it is reached at runtime, either AssertError is thrown or execution is terminated in an

Re: Overflows in Phobos

2016-07-27 Thread qznc via Digitalmars-d
On Wednesday, 27 July 2016 at 07:59:54 UTC, Walter Bright wrote: "The expression assert(0) is a special case; it signifies code that should be unreachable. If it is reached at runtime, either AssertError is thrown or execution is terminated in an implementation-defined manner. Any code after

Re: Overflows in Phobos

2016-07-27 Thread Walter Bright via Digitalmars-d
On 7/27/2016 12:28 AM, Shachar Shemesh wrote: On 27/07/16 10:14, Walter Bright wrote: Thank you. I'd prefer it to say something along the lines that it stops execution at the assert(0) in an implementation-defined manner. This leaves whether messages are printed or not, etc., up to the

Re: Overflows in Phobos

2016-07-27 Thread Shachar Shemesh via Digitalmars-d
On 27/07/16 10:14, Walter Bright wrote: Thank you. I'd prefer it to say something along the lines that it stops execution at the assert(0) in an implementation-defined manner. This leaves whether messages are printed or not, etc., up to the implementation. I don't think the spec should require

Re: Overflows in Phobos

2016-07-27 Thread Walter Bright via Digitalmars-d
On 7/26/2016 11:49 PM, Shachar Shemesh wrote: Current text (after the strange copying corruption): The expression assert(0) is a special case; it signies that it is unreachable code. Either AssertError is thrown at runtime if it is reachable, or the execution is halted (on the x86 processor, a

Re: Overflows in Phobos

2016-07-27 Thread Shachar Shemesh via Digitalmars-d
On 27/07/16 08:50, Walter Bright wrote: On 7/26/2016 10:24 PM, Shachar Shemesh wrote: Most D programmers, however, expect the program not to continue executing past an assert(false). They might see it as a bug. Hence my question whether that means D is not meant for programming in privileged

Re: Overflows in Phobos

2016-07-27 Thread Timon Gehr via Digitalmars-d
On 27.07.2016 07:50, Walter Bright wrote: On 7/26/2016 10:24 PM, Shachar Shemesh wrote: Most D programmers, however, expect the program not to continue executing past an assert(false). They might see it as a bug. Hence my question whether that means D is not meant for programming in privileged

Re: Overflows in Phobos

2016-07-27 Thread Timon Gehr via Digitalmars-d
On 26.07.2016 21:11, Steven Schveighoffer wrote: On 7/26/16 2:44 PM, Timon Gehr wrote: On 26.07.2016 17:44, Johan Engelen wrote: The compiler can assume it is unreachable code, but it has to keep it, That makes no sense. Those two statements are mutually exclusive. I thought that assert(0)

Re: Overflows in Phobos

2016-07-26 Thread Walter Bright via Digitalmars-d
On 7/26/2016 10:24 PM, Shachar Shemesh wrote: Most D programmers, however, expect the program not to continue executing past an assert(false). They might see it as a bug. Hence my question whether that means D is not meant for programming in privileged mode. Obviously, HALT means any

Re: Overflows in Phobos

2016-07-26 Thread Shachar Shemesh via Digitalmars-d
On 27/07/16 08:03, deadalnix wrote: On Wednesday, 27 July 2016 at 03:31:07 UTC, Adam D. Ruppe wrote: On Wednesday, 27 July 2016 at 03:13:38 UTC, Shachar Shemesh wrote: Does that mean D isn't meant to be used to develop code that will run in Ring-0? assert(0) is never supposed to actually

Re: Overflows in Phobos

2016-07-26 Thread deadalnix via Digitalmars-d
On Wednesday, 27 July 2016 at 03:31:07 UTC, Adam D. Ruppe wrote: On Wednesday, 27 July 2016 at 03:13:38 UTC, Shachar Shemesh wrote: Does that mean D isn't meant to be used to develop code that will run in Ring-0? assert(0) is never supposed to actually happen... Though, I do think it might

Re: Overflows in Phobos

2016-07-26 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 27 July 2016 at 03:13:38 UTC, Shachar Shemesh wrote: Does that mean D isn't meant to be used to develop code that will run in Ring-0? assert(0) is never supposed to actually happen... Though, I do think it might be better to make it output `forever: hlt; jmp forever;` which I

Re: Overflows in Phobos

2016-07-26 Thread Shachar Shemesh via Digitalmars-d
On 27/07/16 00:56, Walter Bright wrote: What the assert(0) actually does is insert a HALT instruction, even when -release is used. The spec is poorly worded. Does that mean D isn't meant to be used to develop code that will run in Ring-0? Or do we treat it as a feature that kernel mode

Re: Overflows in Phobos

2016-07-26 Thread Walter Bright via Digitalmars-d
On 7/26/2016 7:28 AM, Timon Gehr wrote: According to the language documentation, the patch does not fix the problem. https://dlang.org/spec/expression.html#AssertExpression "The expression assert(0) is a special case; it signifies that it is unreachable code. [...] The optimization and code

Re: Overflows in Phobos

2016-07-26 Thread Jack Stouffer via Digitalmars-d
On Tuesday, 26 July 2016 at 21:53:48 UTC, Walter Bright wrote: On 7/26/2016 8:24 AM, Robert burner Schadek wrote: A perfect example for an item for your action list. Anybody can work on this! That's the point! Put it on the list so people know.

Re: Overflows in Phobos

2016-07-26 Thread Walter Bright via Digitalmars-d
On 7/26/2016 8:24 AM, Robert burner Schadek wrote: A perfect example for an item for your action list. Anybody can work on this!

Re: Overflows in Phobos

2016-07-26 Thread Steven Schveighoffer via Digitalmars-d
On 7/26/16 2:44 PM, Timon Gehr wrote: On 26.07.2016 17:44, Johan Engelen wrote: The compiler can assume it is unreachable code, but it has to keep it, That makes no sense. Those two statements are mutually exclusive. I thought that assert(0) means that the compiler does not need to check

Re: Overflows in Phobos

2016-07-26 Thread Timon Gehr via Digitalmars-d
On 26.07.2016 17:44, Johan Engelen wrote: On Tuesday, 26 July 2016 at 14:28:48 UTC, Timon Gehr wrote: According to the language documentation, the patch does not fix the problem. https://dlang.org/spec/expression.html#AssertExpression "The expression assert(0) is a special case; it signifies

Re: Overflows in Phobos

2016-07-26 Thread Johan Engelen via Digitalmars-d
On Tuesday, 26 July 2016 at 14:28:48 UTC, Timon Gehr wrote: According to the language documentation, the patch does not fix the problem. https://dlang.org/spec/expression.html#AssertExpression "The expression assert(0) is a special case; it signifies that it is unreachable code. [...] The

Re: Overflows in Phobos

2016-07-26 Thread Robert burner Schadek via Digitalmars-d
A perfect example for an item for your action list.

Re: Overflows in Phobos

2016-07-26 Thread ketmar via Digitalmars-d
On Tuesday, 26 July 2016 at 14:28:48 UTC, Timon Gehr wrote: "The expression assert(0) is a special case; it signifies that it is unreachable code. [...] The optimization and code generation phases of compilation may assume that it is unreachable code." so specs should be fixed. i bet

Re: Overflows in Phobos

2016-07-26 Thread Timon Gehr via Digitalmars-d
On 26.07.2016 00:17, Walter Bright wrote: In poking around in Phobos, I found a number of cases like: https://github.com/dlang/phobos/pull/4655 where overflow is possible in calculating storage sizes. Since allocation normally happens in @trusted code, these are a safety/security hole.

Overflows in Phobos

2016-07-25 Thread Walter Bright via Digitalmars-d
In poking around in Phobos, I found a number of cases like: https://github.com/dlang/phobos/pull/4655 where overflow is possible in calculating storage sizes. Since allocation normally happens in @trusted code, these are a safety/security hole. When reviewing Phobos submissions, please