Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Is this valid C code?

Name: Anonymous 2017-01-02 2:13

char x [5] = { 0xf0, 0x0f, 0xc7, 0xc8 };

main ()
{
void (*f)() = x;
f();
}


Found this on the Everything2 page for the Pentium F00F bug. My question is essentially whether it is indeed valid to write machine code subroutines as byte arrays and call them via a function pointer. Does the Standard have anything to say about this? And is executing code in the data segment even possible on modern architectures?

Name: Anonymous 2017-01-03 12:30

It's creative and unique, not plain illiterate like sounds in space.
sounds in space is a convention, complaining it is as pointless as complaining about soundtracks because hey, in real life there's never a mood-appropriate music playing from nowhere in particular (inb4 dogme95 did exactly that). Dune is creative and unique but if you examine it pedantically by pointing out plot holes or inconsistencies with actual science, it will fall apart. the takeaway from that is that unless your story aims specifically for realism, nitpicking minor details is pointless because those minor details are not why the story is good or bad and if you complain about them, you're the kind of insufferable asshole who insists on arrays not being pointers.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List