Jump to page: 1 2
Thread overview
[Issue 20137] A program crashes at runtime (should be compile error)
Aug 19, 2019
RazvanN
Aug 21, 2019
anonymous4
Aug 21, 2019
Victor Porton
Aug 23, 2019
anonymous4
Aug 23, 2019
Victor Porton
Aug 23, 2019
Simen Kjaeraas
Aug 23, 2019
Victor Porton
Aug 23, 2019
Simen Kjaeraas
Aug 26, 2019
anonymous4
Aug 26, 2019
anonymous4
Aug 26, 2019
anonymous4
August 19, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com
          Component|dmd                         |phobos

--- Comment #1 from RazvanN <razvan.nitu1305@gmail.com> ---
I'm not sure this is a bug. Even if it is, it is not a dmd one. `scoped` is implemented as a template function that returns a `struct Scoped`. `struct Scoped` has an alias this to the class instance and it somehow gets messed up. I suspect this is due to an internal bug in scoped.

--
August 21, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

anonymous4 <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
             Status|NEW                         |RESOLVED
           Hardware|x86_64                      |All
         Resolution|---                         |INVALID
                 OS|Linux                       |All

--- Comment #2 from anonymous4 <dfj1esp02@sneakemail.com> ---
He assigns scoped to SoundCard, and scoped gets deallocated before next statement. This is by design, mark main with @safe attribute to prevent this.

--
August 21, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #3 from Victor Porton <porton@narod.ru> ---
This "by design" is very disgracing. Need to do something.

If to make it more reliable it's needed compiler changes, a new compiler "directive" should be added.

@safe being missing should make harmlessly looking seemingly good program crash without any warning in an unpredictable way!

It is a reliability BUG, not just a misfeature. As it is a bug, fix it.

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #4 from anonymous4 <dfj1esp02@sneakemail.com> ---
Safe D is an ongoing effort to fix such bugs, see
https://dlang.org/spec/memory-safe-d.html
Or do you propose to remove Scoped from phobos?

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #5 from Victor Porton <porton@narod.ru> ---
No, I propose to fix the bug, not to remove a feature.

The measures of https://dlang.org/spec/memory-safe-d.html are not enough, because Scoped is a very special case and need to be done in some special way, to eliminate this blatant reliability BUG.

If it requires compiler changes specifically for Scoped implementation, it should be done, Scoped is a very important construct and deserves special compiler support.

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com

--- Comment #6 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
Scoped!T is like goto - the default advice is "don't use it". When you're ready, you'll know.

Scoped!T should probably be marked as dark magic in the documentation, because that's what it is. It's a useful tool, but you need to know what you're doing, and this should be properly conveyed by documentation.

Beyond that, there is no bug here - the language is doing what it should. This is equivalent to you putting your finger in the circular saw and demanding it be replaced with a hand saw.

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #7 from Victor Porton <porton@narod.ru> ---
It is the same as if you were to say: C does what it should do, it crashes programs. I utterly disagree.

Crash on

T x = Scoped!T();

is a BUG in reliability. Not a bug in the implementation, but a bug in reliability. These are two different kinds of bugs, but both categories are bugs.

By the way, we should raise the task to completely replace Ada. There should be no unpredictable crashes.

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #8 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
There is no unpredictable crash in this case - the crash is perfectly predictable. And no, it's not like saying C does what it should - it's like saying Rust does what it should because you can do unsafe stuff in unsafe blocks. You're punching yourself in the face and telling the doctor it hurts when you do so. The solution is to stop punching yourself in the face.

--
August 26, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #9 from anonymous4 <dfj1esp02@sneakemail.com> ---
(In reply to Victor Porton from comment #5)
> If it requires compiler changes specifically for Scoped implementation, it should be done, Scoped is a very important construct and deserves special compiler support.
Sounds like lint. There's https://github.com/dlang-community/D-Scanner I think it can be taught to detect such Scoped unwrapping.

--
August 26, 2019
https://issues.dlang.org/show_bug.cgi?id=20137

--- Comment #10 from anonymous4 <dfj1esp02@sneakemail.com> ---
Should be detectable by dscanner on syntax level: if rhs is a template named Scoped and lhs is not an `auto` declared variable.

--
« First   ‹ Prev
1 2