Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
dgrunwald
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
7 ms
·
1.
▲
by
dgrunwald
12d ago
I don't know why I wrote the comment about parameters earlier -- (N)RVO is about return values. Those have a different reason for being passed behind a hidden pointer: the class type might have self-referencing pointers, so there must
2.
▲
by
dgrunwald
13d ago
> Memory safety bugs aren't any different from other bugs. This is highly dependent on what kind of software you are writing. On the one end, there's stuff like an image format parser in a browser -- a pure function from untrus
3.
▲
by
dgrunwald
14d ago
The optimization is often possible even if the computer does not see the call, because most (all?) ABIs have always required hidden pointer parameters for class types with non-trivial destructors. https://godbolt.org/z
4.
▲
by
dgrunwald
14d ago
The compiler cannot optimize that into `while(true)` because the original code does not encounter undefined behavior when `limit` is small enough to fit into `int`. What it can do: infer that `limit <= INT_MAX` and use that to optimize t
5.
▲
by
dgrunwald
27d ago
The malicious code could use life-before-main hacks to gain code execution if it's linked at all, even if uncalled. https://grack.com/blog/2026/06/11/life-before-main/
6.
▲
by
dgrunwald
2mo ago
$ORIGIN was only supported when the loader was looking for other dependencies. The loader itself (field PT_INTERP) is loaded by the kernel. So prior to this change, every program must hardcode the absolute path to ld.so. With support for an
7.
▲
by
dgrunwald
2mo ago
> Furthermore parsing JSON or YAML gives you the basic data types like lists and dictionaries. Parsing XML gives you an AST that requires a lot more effort to turn into data in your domain. More precisely: in XML, elements (nodes) are na
8.
▲
by
dgrunwald
3mo ago
`rmdir /s /q` in a command prompt is significantly faster than Windows Explorer. Yes C: is slow due to filters and Dev Drive is faster; but this difference can only be felt when using the command line; Windows Explorer has so much
9.
▲
by
dgrunwald
4mo ago
In our compiler (in a code analysis tool), we have #pragma immutable_macro __attribute__ After this pragma, any attempt to #define/#undef the macro "__attribute__" will be silently ignored. This lets us (or our custom
10.
▲
by
dgrunwald
6mo ago
It's a normal command called "View: Reopen Closed Editor".
11.
▲
by
dgrunwald
6mo ago
Yes `int` acts as if it was a subtype of `float`: https://typing.python.org/en/latest/spec/special-types.html#...
12.
▲
by
dgrunwald
6mo ago
But in Python the type checker does not complain about `x: float = 0`, because for the purpose of type checking (but not at runtime), `int` is considered a subtype of `float`: https://typing.python.org/en/latest/sp
13.
▲
by
dgrunwald
6mo ago
In most languages, `x: float = 0` involves an implicit conversion from int to float. In Python, type annotations have no impact on runtime behavior, so even though the type checker accepts this code, `type(x)` will be `int` -- python acts a
14.
▲
by
dgrunwald
7mo ago
Don't forget the compatibility issues: Fil-C isn't really usable if you mix C with other languages in the process. It's especially problematic to have multiple different garbage collectors; so given the desire to reuse librar
15.
▲
by
dgrunwald
7mo ago
When accessing individual elements, 0-based and 1-based indexing are basically equally usable (up to personal preference). But this changes for other operations! For example, consider how to specify the index of where to insert in a string.
16.
▲
by
dgrunwald
8mo ago
> make sure not to sign into your Microsoft account or link it to Windows again That's not so easy. Microsoft tries really hard to get you to use a Microsoft account. For example, logging into MS Teams will automatically link your l
17.
▲
by
dgrunwald
8mo ago
That loop isn't N²: if there are long sequences of dashes, every iteration will cut the lengths of those sequences in half. So the loop has at most lg(N) iterations, for a O(N*lg(N)) total runtime.
18.
▲
by
dgrunwald
10mo ago
cygwin is a POSIX-emulating library intended for porting POSIX-only programs to Windows. That is: when compiling for cygwin, you'd use the cygwin POSIX APIs instead of the Windows APIs. So anything compiled with cygwin won't be
19.
▲
by
dgrunwald
10mo ago
If you need `0..=n`, you can't write `0..(n+1)` because that addition might overflow.
20.
▲
by
dgrunwald
1y ago
But the source character set remains implementation-defined, so compilers do not have to directly support unicode names, only the escape notation. Definitely a questionable choice to throw off readers with unicode weirdness in the very firs
21.
▲
by
dgrunwald
1y ago
The article is using the Python C API directly. pybind11 is a C++ wrapper that makes the Python API more friendly to use from C++ (e.g. smart pointers instead of manual reference counting)
22.
▲
by
dgrunwald
1y ago
> But if i is indeed put immediately after, then the function should indeed return 5 for n=3. That's not how compilers work. The optimization changing `return i;` into `return 0;` happens long before the compiler determines the stac
23.
▲
by
dgrunwald
2y ago
The problem with `setenv` is that people expect one process to have one set of environment variables, which is shared across multiple languages running in that process. This implies every language must let its environment variables be manag
24.
▲
by
dgrunwald
2y ago
How exactly would that help in this situation? If both Rust and C have independent standard libraries loaded into the same process, each would have an independent set of environment variables. So setting a variable from Rust wouldn't m
25.
▲
by
dgrunwald
2y ago
Yes, that is typically the way to go. Collecting a call stack only requires unwinding information (which is usually already present for C++ exceptions / Rust panics), not full debug symbols. This gives you a list of instruction pointer
26.
▲
by
dgrunwald
2y ago
Caution with these functions: in most cases you need to check not only the error code, but also the `ptr` in the result. Otherwise you end up with `to_int("0x1234") == 0` instead of the expected `std::nullopt`, because these funct
27.
▲
by
dgrunwald
2y ago
> All noexcept does is catch any exception and immediately std::terminate. While that's a possible implementation; the standard is a bit more relaxed: `noexcept` may also call `std::terminate` immediately when an exception is thrown
28.
▲
by
dgrunwald
2y ago
The GC does matter. Most applications are completely fine with having a garbage collector, but they are not fine with having multiple garbage collectors! Mixing multiple garbage collected languages is a recipe for complex bugs. At a minimum
29.
▲
by
dgrunwald
2y ago
There are some static analysis tools that can check this. Cert's SIG30 rule page has a list: https://wiki.sei.cmu.edu/confluence/display/c/SIG30-C.+Call+... Also there's https://clang.llv
30.
▲
by
dgrunwald
2y ago
> If a compiler is certain there's UB should it format the developer's hard drive immediately, or does it have to wait until the program is run before formatting to be standards compliant? The standard has enough variants of UB
More ›