3 ms·
That error is not due to goto, it was just a goto which was errously executed because of badly formatted code. (It looked like the statement was inside an if-bl
by bazoom42 4y ago
That error is not due to goto, it was just a goto which was errously executed because of badly formatted code. (It looked like the statement was inside an if-block due to the indent.)
Pyhon would have prevented this bug, but so would a formatter. Rust also requires braces for if-blocks to prevent this kind of error.
- bitwize 4y ago"The problem isn't C, it's that they weren't using C properly..."
- Karellen 4y agoThat's not really a fair complaint against C, when many safer languages whose syntax derives from C (e.g. javascript) would have the same problem.
- lolcatuser 4y agoBut that is a legitimate problem. Using a language feature that is a known footgun (`if ...` instead of `if {...}`) without being cautious enough to avoid shooting yourself in the foot is not the fault of the footgun, it's the fault of the programmer. Additionally, in the above linked case, the problem isn't a misused `goto`, it's a misused `if ...`. It would be just as problematic if they typed `cleanup_context();` instead of `goto fail;`, but nobody complains about cleaning up state, do they?
- preseinger 4y agoOnce a footgun shoots the feet of enough people, the problem is no longer with the people, it is with the thing that enables the footgun.
- bazoom42 4y agoIt is not a problem specific to C. Any language where indents are independt of semantics is prone to this kind of bug.