![]() |
|
Actually, thats a reason why I never even touched Nix. Besides, being functional and all the hype, but the syntax and naming of the language feels ad-hoc enough for me to never have caught on...
|
![]() |
|
To this day, many C programmers believe that strong typing just means pounding extra hard on the keyboard. Peter van der Linden, "Expert C Programming" |
![]() |
|
FYI, in VS Code, you highlight the error in the terminal, right click and select "copilot explain this." One less layer of indirection. In C++, I ultimately only end up using it for 10% of the errors, but because it's the type of error with a terrible message, copilot sees through it and puts it in plain English. I was so impressed with gpt-4's ability to diagnose and correct errors that i made this app to catch python runtime errors, and automatically make gpt-4 code inject the correction: https://github.com/matthewkolbe/OpenAIError |
![]() |
|
I've found it to have quite poor defaults for its analysis (things like suggesting "use annex k strcpy_s instead of strcpy").
fanalyzer is still by far the easiest to configure.
|
![]() |
|
FWIW I implemented SARIF output in GCC 13 which is viewable by e.g. VS Code (via a plugin) - though the ASCII art isn't. You can see an example of the output here: https://godbolt.org/z/aan6Kfxds (that's the first example from the article, with -fdiagnostics-format=sarif-stderr added to the command-line options) I experimented with SVG output for the diagrams, but didn't get this in good enough shape for GCC 14. |
![]() |
|
Right, but the size of the buffer is given, it doesn't make sense to stomp over end of the callers buffer either, so you can't use pass in something longer than `nbytes` either.
|
![]() |
|
It's really great. Shear amount of work is huge. It seems difficulty level is on par with introducing fat pointers/array views into stdlib and C standard.
|
![]() |
|
strncpy won't always write a trailing nul byte, causing out of bounds reads elsewhere. It's a nasty little fellow. See the warning at https://linux.die.net/man/3/strncpy strlcpy() is better and what most people think strncpy() is, but still results in truncated strings if not used carefully which can also lead to big problems. |
![]() |
|
> Last I checked they're almost as big no-nos as using goto. I don't think so. Gotos are fine, strcat and strcpy without a malloc with the correct size in the same scope is a code smell. |
![]() |
|
Compiling HLL constructs in some of those scenarios ultimately produces a jump statement. So, it makes sense that a higher-level version of a jump would be helpful in the same situations.
|
![]() |
|
-Wstringop-overflow is the first warning I disable because of all the false positives. I doubt the analyze variant would fare any better. |
![]() |
|
Isn't sort of like pulling the battery out of your carbon monoxide detector because the constant beeping is giving you a headache and making you sleepy?
|
![]() |
|
No. -Wstringop-overflow is really broken with a huge amount of false positives. At $JOB we disable it on a line by line basis, but I'm not sure it is worth the effort. |
![]() |
|
Few years before that Stallman personally sabotaged this kind of tooling "because someone might abuse it". LWN did a write-up: https://lwn.net/Articles/629259/ So not surprising gcc devs weren't especially interested in on it, since Lord Stallman can come in and decree it unethical on a whim out of misguided fears. |