Not a big fan of the format of the talk. The guy is a good orator, but it takes ages to go to the point. A bit annoying if you're actually interested in the technical part rather than the jokes.
Yup, I’m not going to burn 54 minutes of my life listening to something that should take 30 seconds to convey.
*(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
151–160 of 199 posts
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#152Earlier quoted context omitted.
Back in the day there were no protections. You could write to any address whether it was used by the CPU for interrupt vectors, part of the OS, hardware addresses, anything.
Sure, but I'm asking if that's something that's enabled by default today or not. I don't see why it's unreasonable for things that were useful "back in the day" to not be available with the default arguments on current versions of compilers but available with certain flags. I'm not sure why my question touched a nerve, because I'm genuinely asking both if I understand correctly and if it's something that needs a flag…
Modern CPUs with virtual memory means the question is a lot more complicated. Every process in a modern OS gets it's own address space so you can write to 0 but it could go anywhere (even virtualized to disk) and all the actual hardware is not directly accessible (must go through the OS).
I'm not sure I'd call this ability "useful" except if you're writing an operating system. This is vast simplification but when your computer boots it's effectively in a mode that allows reading/writing to anywhere. The OS kernel has direct access to all the hardware and then it limits access when running user processes.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#153Earlier quoted context omitted.
I ask it to quote the section and it helps to find. But if you prefer reading the transcript that’s fine too. It’s not a commandment. It’s my sharing what works for me.
Fair enough. I was not criticising you, sorry if it sounded that way. I am just puzzled by instances where it seems an old fashioned approach (such as control-F in this case) would perform at least as well as fancy (and not always reliable) AI techniques.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#154Wait for C++ coder to get disney sponsorship for a stack frame version of/translation to George Lucas expressions / Steven Speilburg expressions.
aka * wars vs. * trek crossover comparisons, perhaps with less () than lisp/scheme take.
Ideally, in UTF format so no "7 samuri/8 bit kleen", AND/OR, lower API, protocol droids distractions.
In interm, learn python, show a python version of beetles 'let it be' and 'eigen a feeling'[1] parody.
Although, perhaps 'irq feeling' more on topic with an appropriate reference to irq hooks & NULL dumps.
Perhaps get DMCA'd by Wierd Al for using wrong character color scheme.
".plan 0[]", long[sigh] different discussion?
[0] : sigh[long] : http://news.ycombinator.com/item?id=3367392
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#155Earlier quoted context omitted.
> that value does not have to be address 0, it could be some other address. That's what the spec says, but are there any computers around anymore where nullptr is not zero? The spec should really go with the times IMHO, old hardware can be supported via platform-specific language extensions.
The cleanest way would probably be to get rid of 0 as a null pointer constant, make its use in contexts that expect a pointer illegal and replace it with an explicit keyword. Of course that would break all existing code that uses 0 or (void*)0 instead of NULL, but if you are out to break things anyway you might as well get rid of 40 year old warts.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#156Earlier quoted context omitted.
Not at all, that is a guarantee that people actually know how to hold the scapel and can enter the operating room safely. A brick layer doesn't turn into a Construction Engineer, only because they think they know everything about building houses, and have somehow built their own during long weekends. Likewise a coder out of a bootcamp, isn't someone versed in what actually entails to be a Software Engineer, regarless…
No, it’s not a guarantee, it’s just a noisy filter with a very high false negative rate and a high enough false positive rate (as visible in malpractice insurance).
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#157Crash? For example test code that makes your app crash, in order to test... say if your crashdumps work as expected?
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#158Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#159Earlier quoted context omitted.
I think an even more accurate analogy would be if a surgeon had some kind of scalpel with a 1 cm limit, but if a surgery suddenly changes in the middle, and suddenly requires a deeper incision, the surgeon has to spend a non-zero amount of time re-configuring the scalpel. This casts flexibility vs safety as a tradeoff, which it is.
Oh, one more refinement: Surgeons are constantly killing people[1], and every time, it turns out it was because the surgeon disabled a known, recommended safety rail, and whenever anyone points out that they should stop disabling the safety rails, they insist that they know how to operate without them, it's those other people that don't. Plus it's sooooo inconvenient for an operation[2] to take five more minutes, the…
Honestly, checklists and procedure matter more than most people want to admit.
Re: *(char*)0 = 0; – What does the C++ programmer intend with this code? [video]
#160When I see that code my head immediately translates to "store a byte with value 0 at memory address zero". 0 the integer needs to be cast to a char * to treat it as a byte address (rather than a word) and the * means "assign to the memory location given by the pointer. I would probably use something like this when hacking on an Apple II with a zero page. I have also written programs that ran on VMS which dumped memor…
You're mostly correct but to be pedantic, in C the literal value 0 does not actually mean address 0. The literal value of 0 is an implementation defined value that represents a null pointer, but that value does not have to be address 0, it could be some other address. This is significant because the following two snippets of code are not required to be equal in C. char* c = (char*)(0); char* d; memset(&d, 0, sizeof(d…