digitalmars.D.learn - assert
- f (9/9) Sep 10 void main()
- f (1/1) Sep 10 i mean , is this a bug?
- Jonathan M Davis (29/30) Sep 10 No, it's not a bug. Assertions with an expression that is known to be fa...
- ryuukk_ (6/10) Sep 11 It is a bug, don't claim it is not, the compiler gives the wrong
- Nick Treleaven (4/8) Sep 11 The behaviour is by design, it is not a bug, it is documented in
- ryuukk_ (7/16) Sep 11 Oh right, "illegal instruction" is what users should read in
- Kapendev (3/20) Sep 11 You can say that the error message is weird with -release, but
- user1234 (3/10) Sep 12 Oh no please stay, your unrecognisable passive aggressive style
- Andy Valencia (10/21) Sep 12 To put it more gently, ryuukk--and following the generally
- Fox (3/3) Sep 11 I don't care about whether it's a bug or not, I just want to
- Bradley Chatha (3/6) Sep 11 Fortunately Godbolt supports D, so it's easy to see that it
- Fox (3/9) Sep 11 This is great, thanks.
- Salih Dincer (6/7) Sep 12 This is not a bug. The problem is due to a misunderstanding of
void main() { assert(false); } dmd -release a.d dmd version 2.109.1 debian bookworm x64 illegal instruction thanks
Sep 10
On Tuesday, September 10, 2024 10:01:53 PM MDT f via Digitalmars-d-learn wrote:i mean , is this a bug?No, it's not a bug. Assertions with an expression that is known to be false at compile time are treated as special. They are always left in the generated code so that they will kill your program if you ever hit that line of code. So, assertions which actually need to be validated at runtime will be compiled out with -release, but assert(false) is always there, and with -release, instead of throwing an AssertError, it immediately terminates the program. One common use case for this would be something like auto foo(int i) nothrow { try { ... } catch(Exception) { assert(false, "It should be impossible for this code to throw."); } } where you have code that you know will never throw given the input that you're giving it, but it's not nothrow, because it could throw under other circumstances. And so in order to call that code within a nothrow function, you wrap it in a try-catch block, and then just in case you screwed up, and it does somehow throw, the assertion is triggered even with -release, and your program is terminated instead of continuing in an invalid state. - Jonathan M Davis
Sep 10
On Wednesday, 11 September 2024 at 06:07:26 UTC, Jonathan M Davis wrote:On Tuesday, September 10, 2024 10:01:53 PM MDT f via Digitalmars-d-learn wrote:It is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a confused user You don't want confused users, you want compiler say what's up, if i type assert, it should assert, end of the storyi mean , is this a bug?No, it's not a bug.
Sep 11
On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote:It is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a confused user You don't want confused users, you want compiler say what's up, if i type assert, it should assert, end of the storyThe behaviour is by design, it is not a bug, it is documented in the spec: https://dlang.org/spec/expression.html#assert-ct
Sep 11
On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote:On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote:Oh right, "illegal instruction" is what users should read in order to "fix" their code I again apologies for being wrong and i apologies again for trying to improve things, i didn't meant to do that, i now may leave againIt is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a confused user You don't want confused users, you want compiler say what's up, if i type assert, it should assert, end of the storyThe behaviour is by design, it is not a bug, it is documented in the spec: https://dlang.org/spec/expression.html#assert-ct
Sep 11
On Wednesday, 11 September 2024 at 10:08:29 UTC, ryuukk_ wrote:On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote:You can say that the error message is weird with -release, but it's not a bug.On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote:Oh right, "illegal instruction" is what users should read in order to "fix" their code I again apologies for being wrong and i apologies again for trying to improve things, i didn't meant to do that, i now may leave againIt is a bug, don't claim it is not, the compiler gives the wrong information, wich lead to a confused user You don't want confused users, you want compiler say what's up, if i type assert, it should assert, end of the storyThe behaviour is by design, it is not a bug, it is documented in the spec: https://dlang.org/spec/expression.html#assert-ct
Sep 11
On Wednesday, 11 September 2024 at 10:08:29 UTC, ryuukk_ wrote:On Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote:Oh no please stay, your unrecognisable passive aggressive style is so useful.On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote:[...] I again apologies for being wrong and i apologies again for trying to improve things, i didn't meant to do that, i now may leave again
Sep 12
On Thursday, 12 September 2024 at 22:34:04 UTC, user1234 wrote:On Wednesday, 11 September 2024 at 10:08:29 UTC, ryuukk_ wrote:To put it more gently, ryuukk--and following the generally congenial and informative flavor of communications here--you may not realize that your messages have an abrasive feel to them. It really does make a difference to be polite and even respectful when people seek to help you by answering your questions. Showing gratitude makes it much more likely that these valuable contributors stay around and answer newbie questions in the future. AndyOn Wednesday, 11 September 2024 at 09:14:39 UTC, Nick Treleaven wrote:Oh no please stay, your unrecognisable passive aggressive style is so useful.On Wednesday, 11 September 2024 at 08:08:45 UTC, ryuukk_ wrote:[...] I again apologies for being wrong and i apologies again for trying to improve things, i didn't meant to do that, i now may leave again
Sep 12
I don't care about whether it's a bug or not, I just want to learn What illegal instructions did this "assert(false);" code create?
Sep 11
On Wednesday, 11 September 2024 at 12:17:02 UTC, Fox wrote:I don't care about whether it's a bug or not, I just want to learn What illegal instructions did this "assert(false);" code create?Fortunately Godbolt supports D, so it's easy to see that it generates `ud2` on x86(_64): https://godbolt.org/z/4zq67boMW
Sep 11
On Wednesday, 11 September 2024 at 16:40:05 UTC, Bradley Chatha wrote:On Wednesday, 11 September 2024 at 12:17:02 UTC, Fox wrote:This is great, thanks.I don't care about whether it's a bug or not, I just want to learn What illegal instructions did this "assert(false);" code create?Fortunately Godbolt supports D, so it's easy to see that it generates `ud2` on x86(_64): https://godbolt.org/z/4zq67boMW
Sep 11
On Wednesday, 11 September 2024 at 04:01:53 UTC, f wrote:i mean , is this a bug?This is not a bug. The problem is due to a misunderstanding of the -release parameter. The following related topic opened by Steven and the answers given by Walter are really valuable: https://forum.dlang.org/thread/pkeasakdbugctqdyetnw forum.dlang.org SDB 79
Sep 12