|
Polio Vax Scene posted:my first reaction was "well then the sqrt should check for float input and automatically call sqrtf and only do the expansion if explicitly requested in the call" but now I'm thinking it's probably better to do the opposite and live with hunting down the performance impact and not cause something to explode at NASA It's mindboggling that -Wdouble-promotion isn't included in -Wall, but you should be using it
|
# ? Feb 23, 2022 17:52 |
|
|
# ? May 17, 2024 16:26 |
|
more falafel please posted:It's mindboggling that -Wdouble-promotion isn't included in -Wall, but you should be using it I should probably re-evaluate my warning lists Anything useful not in -Wall -Wextra -Wpedantic Or useful things I'd be missing with those enabled? Mostly been writing C for late 90s and early 2000s handheld game consoles.
|
# ? Feb 23, 2022 19:13 |
|
Double promotion warnings can be really handy when developing for microcontrollers that only support single precision. Soft double vs hard float is a stark difference in performance.Athas posted:I have spent too much of my life chasing down performance bugs because some C code dared to call sqrt(x) where x was a float, because sqrt() is defined for doubles, and so this involves a silent expansion to double precision and a full double precision square root. (The solution is to use sqrtf() instead.)
|
# ? Feb 23, 2022 20:02 |
|
It's always fun to see significantly different worlds in term of target hw. We target broadwell as minimum due to the instruction set, and our baseline expectation is ~4 gigs of ram per core.
|
# ? Feb 23, 2022 21:14 |
|
Xarn posted:It's always fun to see significantly different worlds in term of target hw. We target broadwell as minimum due to the instruction set, and our baseline expectation is ~4 gigs of ram per core. Current target has 64K ram. Max artifact size is a couple megabit
|
# ? Feb 23, 2022 21:34 |
|
My minspec is Nintendo Switch, although the project I'm on now runs on very low spec PCs, so something like 2GB total memory usage is the budget. Of course on consoles the hardware is fixed and well understood, so we can use whatever is there.
|
# ? Feb 23, 2022 21:41 |
|
NihilCredo posted:I think what +0 really means is "a number between 0 and 2 ^ -126", and -0 really means "a number between - (2 ^ -126) and 0". Or maybe -127 depending how you do rounding. This is a common misconception, or is that the joke?
|
# ? Feb 23, 2022 22:57 |
|
In 25 years of programming for dollars I have only ever had 1 problem stemming from floats, and that was in some third-party code that was comparing floats directly with ==. It worked OK in gcc <N> and then started failing in gcc <N+1>.
|
# ? Feb 23, 2022 23:00 |
|
I've run into precision issues in graphics shaders.
|
# ? Feb 23, 2022 23:08 |
|
I had precision issues one time when I was porting a custom C++ game engine to C# for reasons that are way too stupid to go into here (short version: had to be on Windows Phone 7, which didn't allow any native code). A bunch of math functions in C# land are double-only, and transcribing a relatively simple expression could end up converting from float->double->float like 6 or 8 times. Converting all the inputs to double at the start and then converting the result to float made the error basically go away. Again, the sort of thing that would only happen when you're transcribing code that's supposed to be floats all the way down to a mixed environment.
|
# ? Feb 24, 2022 00:04 |
|
leper khan posted:I should probably re-evaluate my warning lists -Wformat-nonliteral: Warn if a printf/scanf format string is not a string literal (or set -Wformat=2 instead of the default you'll get with Wall) -Wcast-qual: Warn if a cast discards a qualifier (i.e. const int* => int*) -Wconversion: Warn on implicit conversions that potentially change values (i.e. abs(2.1))
|
# ? Feb 24, 2022 00:12 |
|
Foxfire_ posted:Some more: These are good. Some other good ones we use that are not too noisy: * -Wformat-type-confusion: Warn if an argument to printf() doesn't match the expected type for the placeholder. * -Wconditional-uninitialized: Warn if a variable is uninitialized upon use/capture. * -Widiomatic-parentheses: Warn if you use the result of an assignment without explicitly wrapping it in parens. (This catches "if (x = 10)" style typos.) * -Wbad-function-cast: Warn if you cast fxnptrs to incompatible types. * -Wunreachable-code: Warns if you've got code that will never be executed. Some stuff that is noisier but might be worthwhile depending on your tolerance: * -Wswitch-enum: Warns if you have a switch on an enum and don't cover all cases of the enum, either with explicit cases or default. * -Wimplicit-fallthrough: Warns if you have a fall-through between switch cases without using [[fallthrough]]. * -Wfloat-equal: Warn if comparing floating-point types with ==/!=.
|
# ? Feb 24, 2022 00:47 |
|
I love that -Wall doesn't enable all warnings
|
# ? Feb 24, 2022 01:11 |
|
-Wsome
|
# ? Feb 24, 2022 01:12 |
|
You can get all sorts of fun memory corruption if you break invariants on things like std::sort or std::set by passing in data that isn't actually strictly ordered by std::less.
|
# ? Feb 24, 2022 01:13 |
|
Presto posted:In 25 years of programming for dollars I have only ever had 1 problem stemming from floats, and that was in some third-party code that was comparing floats directly with ==. It worked OK in gcc <N> and then started failing in gcc <N+1>. ps. don't ask me about it
|
# ? Feb 24, 2022 01:45 |
|
HappyHippo posted:I love that -Wall doesn't enable all warnings It's ridiculous, but if -Wall did enable all warnings, no one would use it. I don't think I've ever worked on a project that would pass -Wunreachable-code, for instance, and no one is gonna have time to get rid of all the unreachable code in, say, UE4
|
# ? Feb 24, 2022 02:26 |
|
-Weverything actually does turn on all warnings with clang, and using it requires turning a bunch of warnings back off.more falafel please posted:It's ridiculous, but if -Wall did enable all warnings, no one would use it. I don't think I've ever worked on a project that would pass -Wunreachable-code, for instance, and no one is gonna have time to get rid of all the unreachable code in, say, UE4 That's uh, kinda strange. -Wunreachable-code only catches things like code after an unconditional return and a codebase that'd be difficult to get passing it is in really dire shape.
|
# ? Feb 24, 2022 03:46 |
|
You've never used macros that contain a conditional, and the value passed into the macro is sometimes a constant?
|
# ? Feb 24, 2022 03:57 |
|
My favorite floating point problem was helping someone debug their lua code for some game plugin and realizing that somehow all comparisons with NaN were returning true.
|
# ? Feb 24, 2022 03:57 |
|
Absurd Alhazred posted:-Wsome -Wjust-those-that-trigger-on-jeffs-code-but-not-those-which-trigger-on-mine
|
# ? Feb 24, 2022 03:59 |
|
Dylan16807 posted:My favorite floating point problem was helping someone debug their lua code for some game plugin and realizing that somehow all comparisons with NaN were returning true.
|
# ? Feb 24, 2022 04:25 |
|
Plorkyeran posted:-Weverything actually does turn on all warnings with clang, and using it requires turning a bunch of warnings back off. The recommended use pattern is to periodically turn it on to find interesting warnings, turn those on, and then turn it back off in your regular builds. Probably not a bad idea to also accumulate the warnings you’re definitely not interested in so you don’t waste your time with them when you repeat this investigation.
|
# ? Feb 24, 2022 04:44 |
|
There are options to disable warnings for specific blocks of code through the preprocessor. They're not standard across compilers but at least gcc and clang agree on how to do them. Maybe it'll be in the standard someday.
|
# ? Feb 24, 2022 04:47 |
|
Zopotantor posted:-Wjeff
|
# ? Feb 24, 2022 05:19 |
|
Doc Hawkins posted:-Wgeoff
|
# ? Feb 24, 2022 05:21 |
|
Jabor posted:You've never used macros that contain a conditional, and the value passed into the macro is sometimes a constant? Clang does not warn about unreachable code inside macro expansion.
|
# ? Feb 24, 2022 05:45 |
|
Plorkyeran posted:-Weverything actually does turn on all warnings with clang, and using it requires turning a bunch of warnings back off. Hmm, ok. I'm probably conflating the clang flag with like, a full fledged linter. I've never tried turning -Weverything on on UE4, it might be fun (it would not be fun)
|
# ? Feb 24, 2022 06:54 |
|
The problem with just Weverything for large codebases is that everything will get buried under an absolute fuckton of Wc++98-compat, so turn that off first You will also find a bunch of warnings that are very heuristical and will need to ignore, but sometimes it does find useful stuff.
|
# ? Feb 24, 2022 07:38 |
|
Xarn posted:It's always fun to see significantly different worlds in term of target hw. We target broadwell as minimum due to the instruction set, and our baseline expectation is ~4 gigs of ram per core. It's not just a footprint thing. I do high performance computing, and if you unnecessarily use double precision, you'll lose half your memory bandwidth and half your SIMD lanes. Storage capacity isn't so important. And of course, on commodity GPUs the loss is even more stark due to market segmentation (I think double precision is something like 32x or 64x slower on NVIDIAs commodity GPUs these days).
|
# ? Feb 24, 2022 07:44 |
|
toiletbrush posted:ask me about my previous job where they wrote their new finance reconciliation microservice using typescript and the problems we had with it you are in a safe space. share your pain, friend
|
# ? Feb 24, 2022 08:09 |
|
A dumb question: Isn't there huge amounts of user friendly tooling that makes C easy and safe by now?
|
# ? Feb 24, 2022 08:09 |
|
Ola posted:A dumb question: Isn't there huge amounts of user friendly tooling that makes C easy and safe by now? It's not user friendly. As a small example, the last few pages of this thread lists important warning that are not turned on by default, and also not turned on when you ask for "all" warnings.
|
# ? Feb 24, 2022 08:16 |
|
Athas posted:It's not user friendly. As a small example, the last few pages of this thread lists important warning that are not turned on by default, and also not turned on when you ask for "all" warnings. But that's the compiler. I was thinking you could do this in VS Code or some snazzy JetBrains product where friendly plugins would shower you with sage advice.
|
# ? Feb 24, 2022 08:26 |
|
Ola posted:But that's the compiler. I was thinking you could do this in VS Code or some snazzy JetBrains product where friendly plugins would shower you with sage advice. “Surely that’s been fixed by now” is a question asked many times. The answer is (almost) always the same.
|
# ? Feb 24, 2022 09:06 |
|
Ola posted:A dumb question: Isn't there huge amounts of user friendly tooling that makes C easy and safe by now?
|
# ? Feb 24, 2022 12:10 |
|
Ola posted:But that's the compiler. I was thinking you could do this in VS Code or some snazzy JetBrains product where friendly plugins would shower you with sage advice. I like clion. But mostly because it makes finding docs easier and matches the workflows I have in C#. It does not prevent me from being Very Dumb any more than the compiler did before. Recently I burned a day to it's non-standard cmake targets support. And another day to cmake trying (and failing) to get a targets file set up for my compilers. I've decided to just stick with makefiles, which are recently supported in clion anyway. Granted, I'm using really weird tool chains (I'd be surprised if there were dozens of people working with them today).
|
# ? Feb 24, 2022 13:40 |
|
Jabor posted:You've never used macros that contain a conditional, and the value passed into the macro is sometimes a constant?
|
# ? Feb 24, 2022 15:18 |
|
ExcessBLarg! posted:Err, no. I don't think I have. That's a weird thing to do. assert(0)? assert(!"bad foo in bar()")? I don't think it's that weird or uncommon.
|
# ? Feb 24, 2022 15:21 |
|
|
# ? May 17, 2024 16:26 |
|
Winter Stormer posted:assert(0)? assert(!"bad foo in bar()")? I don't think it's that weird or uncommon.
|
# ? Feb 24, 2022 15:36 |