Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
ChrisSD
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
37 ms
·
331.
▲
by
ChrisSD
6y ago
Detecting UB is far harder than the compiler simply assuming there is no UB. That said, there are already tools to do it for some cases (but far from all). They're not often used in C/C++, perhaps because they're slow.
332.
▲
by
ChrisSD
6y ago
This is a standalone sequel to "Pointers Are Complicated, or: What's in a Byte?" ( https://www.ralfj.de/blog/2018/07/24/pointers-and-bytes.html ). Which has been discussed on HN 2020: https
333.
▲
Pointers Are Complicated II, or: We need better language specs
(ralfj.de)
262 points
by
ChrisSD
6y ago
|
133 comments
334.
▲
by
ChrisSD
6y ago
I'm not sure there's a "best way" aside from being vigilant. * Don't blindly add everything to git. * Check staged files before commit. * Store secrets separately, outside of your git folder (e.g. use another folder
335.
▲
by
ChrisSD
6y ago
Note that nowadays the preferred way to handle null pointers in APIs is the `Option<NonNull>` type. This unfortunately wasn't available in Rust 1.0. https://doc.rust-lang.org/std/ptr/struct.NonNull.html
336.
▲
by
ChrisSD
6y ago
Judging from how infrequently it's maintained and the many broken links, I think it's safe to say nobody is being paid to edit this part of the wiki.
337.
▲
by
ChrisSD
6y ago
I think JS' early design flaws were a result of being written in a day more than anything to do with a specific purpose (I exaggerate but not by much). Though it is true that most people at the time used JS (if they used it) for much s
338.
▲
by
ChrisSD
6y ago
NuShell is also attempting this. Both are cross platform. https://github.com/nushell/nushell
339.
▲
by
ChrisSD
6y ago
I'm certainly not against micro-optimizations. But they are very context sensitive and cannot be done without proper profiling of the whole program using representative workloads. I find people are often writing spaghetti code because
340.
▲
by
ChrisSD
6y ago
Already this is essentially the ethos of large software companies like Google, et al. An employee is a cog that can be moved to any project or replaced/discarded as needed. [Exceptions are of course made for a handful of people they ac
341.
▲
by
ChrisSD
6y ago
In my experience few people think that optimizations are to be avoided at all costs. Whereas it's very very common for people to try micro optimizing their code as they write it. Generally speaking it's much easier to profile and
342.
▲
by
ChrisSD
6y ago
It looks like cachedir yanked version 0.1.1. This is usually only done when a very serious issue is discovered, though I don't know what the reason is in this case. https://crates.io/crates/cachedir
343.
▲
by
ChrisSD
6y ago
Well if you really want to you can get the output handle from the PEB[0]. You can then call NtWriteFile[1] using syscall `0x0008` (Windows 10 x64 only)[2]. [0]: https://processhacker.sourceforge.io/doc/struct___r_t_l___
344.
▲
by
ChrisSD
6y ago
Ok, I've just tried that but I also needed to add `/force` otherwise it complained about missing symbols. So the full compile line is: cl small2.c /link /force /nodefaultlib /entry:_start /subsystem:
345.
▲
by
ChrisSD
6y ago
The Win32 loader will always load kernel32 no matter what. You don't even need it in your import table. It's just a matter of finding where it's loaded and calling into the right functions.
346.
▲
by
ChrisSD
6y ago
Or you can just use the "Reset PC” feature and disable "Restore preinstalled apps" to reinstall the OS without the OEM bloat.
347.
▲
by
ChrisSD
6y ago
I tried your program with MSVC using the following command: cl small2.c /MD /link /entry:_start /subsystem:CONSOLE kernel32.lib It's 5kb.
348.
▲
by
ChrisSD
6y ago
Have you actually tried this? Merging .data into .text doesn't work. The binary doesn't run and there's this link warning: > LINK : warning LNK4254: section '.data' (C0000040) merged into '.text' (60000
349.
▲
by
ChrisSD
6y ago
Have you actually tried this on MSVC? This is my program. I created a file called `small.c` #include <stdio.h> int main(void) { puts("Hello World!"); return 0; } I then compiled it usin
350.
▲
by
ChrisSD
6y ago
This is the first time in a long time I've heard anyone refer to cmd as a "good tool". It's a legacy from DOS. Not in the literal sense of course but in the sense of the builtins, syntax and the horrendous BAT. Mind you
351.
▲
by
ChrisSD
6y ago
More or less. Though I'd rephrase your description of WSL1 as "Linux for the NT kernel". In that sense "Win32" (the API used by Windows programs) could also be described as "Win32 for the NT kernel". They
352.
▲
by
ChrisSD
6y ago
It's invalid according to the spec. They are permanently reserved code points for use in UTF-16. > The definition of UTF-8 prohibits encoding character numbers between U+D800 and U+DFFF, which are reserved for use with the UTF-16 en
353.
▲
by
ChrisSD
6y ago
Building llvm is the most memory intensive part of compiling Rust itself. You can, I believe, skip this and use pre-built llvm binaries.
354.
▲
by
ChrisSD
6y ago
83 - 80 = 3 Therefore version 83 is 3 versions ahead of version 80. Note that "version" in this context is shorthand for "major version". It does not include minor patches that only fix a bug or security issue. Each new
355.
▲
by
ChrisSD
6y ago
The title doesn't appear to match the text. It seems to be mostly a list of things that might trip up Linux developers when moving to Windows. Which is fair enough but not why I clicked this link. But to address the list's content
356.
▲
by
ChrisSD
6y ago
They're "highlighting" it AFTER you "agreed". Not before you agree to it. What kind of ethics is that? "I'll screw you over but I'll admit to it afterwards"?
357.
▲
by
ChrisSD
6y ago
The article doesn't exactly make a case against it. It even explicitly says it's useful! It just says making a newtype isn't as strong a guarantee as a proper type. Newtypes do work to assert certain checks have already been
358.
▲
by
ChrisSD
6y ago
Why not? That would seem useful if other code depends on having a validated email address.
359.
▲
by
ChrisSD
6y ago
Wait are we seriously at the point where XP is now considered "super no-cruft and lightweight"? XP? How times have changed.
360.
▲
by
ChrisSD
6y ago
I can somewhat understand having to compile for XP (it's been 20 years but... legacy, I get it). However compiling on XP must be hell. Do you mind me asking what you do that requires this?
More ›