Earlier quoted context omitted.
Modern C still promptly decays an array to a pointer, so no array bounds checking is possible. D does not decay arrays, so D has array bounds checking. Note that array overflow bugs are consistently the #1 problem with shipped C code, by a wide margin.
The thing is though that even with array bounds checking built into the language, out of bounds access due to programming error can still be attempted. Only this time it's safer because an attacker can't use the bug (which still exists) to access memory outside of bounds. In any case, the program still doesn't work as intended (has bugs) because the programmer has attempted, or allowed the attempt, to access out of b…
The C23 edition of Modern C
321–330 of 360 posts
Re: The C23 edition of Modern C
#322Earlier quoted context omitted.
I've been using C++ for the longest time, and I would never give up destructors to switch to C. For your particular use case, have you considered C#? VS works much more nicely with it.
Yeah, I did. I want something low level and cross platform, including mobile. I think when I tried the C# for iOS stuff, nothing worked. But it's probably too much VM/runtime for me anyway, for this project.
Re: The C23 edition of Modern C
#323Earlier quoted context omitted.
Arm is bi-endian and is alive in most phones. I agree with another GP's comment that modern doesn't mean popular/widely used.
The book does say "Both orders are commonly used by modern processor types". I'd say this sentence is quite misleading, since it would lead you to believe two falsehoods: 1. That both byte orders are equally prevalent in the wild, particularly in systems that are expected to run modern C code. 2. That both byte orders are equally likely to be found in "modern" (new or updated) processor design. It's not entirely inco…
Re: The C23 edition of Modern C
#324> The storage order, the endianness, as given for my machine, is called little-endian. A system that has high-order representation digits first is called big-endian. Both orders are commonly used by modern processor types. Some processors are even able to switch between the two orders on the fly. Calling big endian "commonly used by modern processor types" when s390x is really the only one left is a bit of a stretch…
Isn't Sparc big-endian?
Re: The C23 edition of Modern C
#325Earlier quoted context omitted.
MIPS is still quite alive in consumer networking hardware.
Learning MIPS assembly currently using mars and QtSpim. Any recommended hardware I should use for bare metal development messing around? Hopefully priced like a SBC like the raspberry pi. Want to move from making basic programs like adding, messing with functions, etc and bring my MIPS assembly up to a real hardware environment.
Re: The C23 edition of Modern C
#326char* thing; // good
char *thing; // bad
This ... is awesome. As a C++ "native" I've always found the "star on the right" thing to be really horribly confusing.
Re: The C23 edition of Modern C
#327Wait, C programmers now put the star on the left hand side? char* thing; // good char *thing; // bad This ... is awesome. As a C++ "native" I've always found the "star on the right" thing to be really horribly confusing.
// mutable pointer to mutable data:
char * str;
// Immutable pointer to immutable data:
char const*const str;
// Mutable pointer to an immutable pointer to a mutable pointer to immutable data:
char const**const* strs;
Re: The C23 edition of Modern C
#328Earlier quoted context omitted.
The PDP-11 that C originally targeted had address modes to support the stack. Pre-increment and post-decrement therefore did not require a separate instruction; they were free. After the PDP-11 went the way of the dodo, both forms took a machine cycle so it (mostly) became a stylistic issue. (The two operators have different semantics, but the trend to avoid side-effects in expressions means that both are most often…
Please explain what you mean by "a separate instruction".
Re: The C23 edition of Modern C
#329Personally this[1] just makes C much more complicated for me, and I choose C when I want simplicity. If I want complicated, I would just pick C++ which I typically would never want. I would just pick Go (or Elixir if I want a server). "_BitInt(N)" is also ugly, reminds me of "_Bool" which is thankfully "bool" now. [1] guard, defer, auto, constexpr, nullptr (what is wrong with NULL?), etc. On top of that "constexpr" a…
> If I want complicated, I would just pick C++ which I typically would never want In my opinion, complexity doesn't scale linearly like this. Sometimes, in fact often times, having more complex tools means a simpler process and end result. It's like building a house. A hammer and screwdriver are very simple. A crane is extremely complex. But which simplifies building a house? A crane. If I wanted to build a house wit…
The constraints of the tool are inherited in the program; if the constraints encourage better design, then the program will have a better design. You benefit from the language providing a path of least resistance that forces intentionality. That intentionality makes the code easier to reason about, and less likely to contain bugs.
You do pay for this by writing more boilerplate, and by occasionally having to do some dirty things with void pointers; but these will be the exception to the rule, and you'll focus on them more since they are so odd.
Re: The C23 edition of Modern C
#330Earlier quoted context omitted.
The book does say "Both orders are commonly used by modern processor types". I'd say this sentence is quite misleading, since it would lead you to believe two falsehoods: 1. That both byte orders are equally prevalent in the wild, particularly in systems that are expected to run modern C code. 2. That both byte orders are equally likely to be found in "modern" (new or updated) processor design. It's not entirely inco…
Don't a bunch of web protocols use big endian?