back
user profile
uecker
2,141karma·1,822submissions·April 14, 2020
about
Computational Magnetic Resonance Imaging, Real-time Magnetic Resonance Imaging, GCC Contributor, BART Toolbox, Member of ISO C WG14
recent activity (1,822 total)
comment
Household prices are meaningless in this context, because they are artificially kept low in France and sometimes are affected by taxes and fees elsewhere. Here are spot marked prices:
https:/…
comment
Yes, this is people with pre-C99 compilers that do not support variably modified types sometimes do. It is horrible (although there are some use cases).
comment
You are right that one problem in C is that it is too inconvenient to do the right thing. A safe buffer abstraction should be included in the standard library. Still, I already saw bad Rust code using…
comment
How would you express a 2D memory layout with only pointers?
comment
Tracking sizes for purposes of bounds checking is QoI and I think this is perfectly fine. But here we can also recover the size with sizeof, so it is also required for compliance: https://g…
comment
If you think about arrays as pointers, you will get a lot of things wrong, e.g. float m[10][10]; it not a an array of pointers, but a 2D dimensional array with 2D memory layout.
comment
I plan to bring such a proposal forward for the next version. Note that C already has everything to do this without much overhead, e.g. in C23 you can write: int N = 10;
char buf[N] = { };
au…
comment
There are many possible reasons why LNT may not be exactly right, but misrepresenting it as anything else than the current best assumption is dishonest in my opinion. I am not aware of hard evidence …
comment
Basically, there is lot of empirical data which can be described by a linear relationship. Of course, if you go to even lower doses then the effect size becomes smaller and it becomes harder to show …
comment
As a physicist and full professor in medical imaging I can ensure you somewhat authoritatively: You can simply disregard every clown on the internet who dismisses linear no threshold out of hand. Th…
comment
It is also really easy in C to have a safe abstraction for buffers that check payload length and does not copy blindly. Why so few people use such abstractions I do not know, but I guess once Rust is…
comment
One could rewrite the C code to pass a pointer to an array with a length in the function prototype. Then you could also get bounds checking in C with UBSan. https://godbolt.org/z/…
comment
Thanks. This is exactly my point. Instead of Rust, we could use a subset of C with suitable annotations and will not require any more annotations than Rust.
comment
A library can do the memory management for you: string a = string("test");
string b = string(" this");
string n = string_concat(a, b);
...
comment
This is the fallacy: A cast does not make code safer you have to use it for regular code that has no issue. Because a linter warning about that is just noise. By example illustrated a bug in the C++ …
comment
People who do not want to write safe code will also not use Rust. (Or then use unsafe Rust a lot). If you want your programmers to write safe code and are in a position to force this, it makes no diff…
comment
Isn't this confusing memory safety with safety?
comment
I think showing with static analysis that existing C code is safe is very hard. But if you start with modern and cleanly written C and avoid certain techniques (such as type punning) I think it is cle…
comment
I like C more than Rust because for my taste, Rust is too complex. I also like that C has fast built times which is important to me. C is also far more portable and has a huge ecosystem. Another big …
comment
But you can automatically derive a lot of information, e.g. after if (!x) return;
you know that x is non-zero etc. Or after x = malloc()
you can know that x is - at this point - a point…
comment
In C you could write or have a macro which does the cast. int *p = malloc(sizeof *p);
In C++ you would have to add an explicit cast, which would not make it safer: int *p = (int*)malloc(s…
comment
If you code them by hand, then yes. If you a library, then it is the same. It is certainly true that the C++ standard library provides more functionality out of the box.
comment
While the size of the VLA is not (usually) known at compile time, it is part of its type and known at run-time (it is a dependent type). And if you use a pointer to the VLA (and not a decayed pointer)…
comment
I personally found it very relieving when I switched from C++ to C. (and I also rewrote some stuff, it did not get more complex.) I find readability of modern C code much better than C++. In C you s…
comment
One can hide internal representations just fine in C using pointers to incomplete struct types with the definition of the struct and the implementation of the functions operating on it in a separate f…
comment
I meant today, not in the past when C did not yet have prototypes. This is irrelevant today.
comment
In what sense is C++ more strongly typed than C?
comment
Regarding the second point. Sure the program went wrong because it was wrong. But the damage it can do when something went wrong when this can affect previous behavior is much higher. Being able to pr…
comment
It is unclear why it has failed to catch on. One reason probably was that Microsoft decided at one point that it will not support C99 because everything should program in C++ which put a damper on th…
comment
The condition is always stated in the C standard. "if ... the behavior is undefined". An optimizer is not in general allowed to re-order operations. It is allowed to do this only if it can…