Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
December 17, 2019 Passing stack allocated string to `assert` | ||||
---|---|---|---|---|
| ||||
This code compiles with DMD 2.089.0 with the `-dip1000` flag: void main() @safe { char[10] buffer = "0123456789"; assert(false, buffer[]); } Running this code will obviously assert, but the assert message contains garbage. Should DIP1000 be able to catch this? -- /Jacob Carlborg |
December 17, 2019 Re: Passing stack allocated string to `assert` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Tuesday, 17 December 2019 at 08:47:49 UTC, Jacob Carlborg wrote:
> This code compiles with DMD 2.089.0 with the `-dip1000` flag:
>
> void main() @safe
> {
> char[10] buffer = "0123456789";
> assert(false, buffer[]);
> }
>
> Running this code will obviously assert, but the assert message contains garbage. Should DIP1000 be able to catch this?
>
> --
> /Jacob Carlborg
Yes, depending on which druntime function the assert is lowered to.
|
December 17, 2019 Re: Passing stack allocated string to `assert` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Petar Kirov [ZombineDev] | On Tuesday, 17 December 2019 at 09:21:42 UTC, Petar Kirov [ZombineDev] wrote:
> On Tuesday, 17 December 2019 at 08:47:49 UTC, Jacob Carlborg wrote:
>> This code compiles with DMD 2.089.0 with the `-dip1000` flag:
>>
>> void main() @safe
>> {
>> char[10] buffer = "0123456789";
>> assert(false, buffer[]);
>> }
>>
>> Running this code will obviously assert, but the assert message contains garbage. Should DIP1000 be able to catch this?
>>
>> --
>> /Jacob Carlborg
>
> Yes, depending on which druntime function the assert is lowered to.
But if it's not lowered to a template, but to an extern(C) funcion, like most of the old runtime functions, it's not surprising that it didn't check it thoroughly. We really need to phase out those runtime functions from druntime.
|
December 18, 2019 Re: Passing stack allocated string to `assert` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On 12/17/2019 12:47 AM, Jacob Carlborg wrote:
> This code compiles with DMD 2.089.0 with the `-dip1000` flag:
>
> void main() @safe
> {
> char[10] buffer = "0123456789";
> assert(false, buffer[]);
> }
>
> Running this code will obviously assert, but the assert message contains garbage. Should DIP1000 be able to catch this?
Please add to bugzilla.
|
December 21, 2019 Re: Passing stack allocated string to `assert` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On 2019-12-18 23:25, Walter Bright wrote: > Please add to bugzilla. Done: https://issues.dlang.org/show_bug.cgi?id=20461. -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation