
Read each question carefully, and if you need clarification, go back to kindergarden. Ready? Share your score only.
- Do you know the difference between architecture and instruction set?
- Do you know why it is possible to assemble code with pointer arithmetic?
- Do you know why bottom-up parsers can represent more grammars than top-down ones?
- Do you know why, in C++,
class Foo { char bar; int baz; };has size 8?- Do you know why, in C23,
struct Foo { typeof('c') bar; char baz[4]; };has size 8?- Do you know how to change the expected flow of a program using pointers?
- Do you know which one of these is defined,
(struct foo){ -1 }or(struct foo){ .bar = -1 }?- Do you know why you shouldn't let an N-dimention array decay?
- Do you know the scarcest resource a well-made loop in shellscript wastes on a server? (it isn't hardware)
>>2992 (OP)
did you have to post the frog? I don't mind it myself much but it's the kind of stuff people might want to leave behind here.
>>3009
I see. However it does appear to have been adopted by actual Nazis later on. It's kind of conflicting because the creator himself didn't want that.
https://www.theguardian.com/books/2019/jun/13/pepe-the-frog-creator-wins-15000-settlement-against-infowars

>>2992 (OP)
i was gonna wait to poast on this one since my job as a pythonista has atrophied my brain but since the thread is being derailed ill give it a shot, this is one of the fun threads I liked on /g/.
- i suppose an example of architecture is x86 vs ARM i dunno about instruction sets
- uhhh cause like youre just pointing at the instructions in memory to run
- i dunno
- padding to 4-byte increments
- i suppose for the same reason as 4) , admittedly i did a quick google for typeof cause i thoguht it was the same as typedef i dont recall using this operator in my clown college classes
- calling a function pointer by indexing it into an array
- i think
(struct foo) { -1 }cause of initializer syntax although i might be confusing c++, i think for the dot syntax of the latter you need to specify the type ofbarbeforehand- i made a snake game in the terminal in c a year or two ago and i knew why but now i forgot
- i have nary a clue of this one
back to being off topic i wouldn't put apu in the same tier as pepe, apu is plenty wholesome while pepe has a negative emotional aura

>>3013
I can tell u are a python affecionado
>>2992 (OP)
- I dont, I usually see the two words bundled together into one concept: ISA. I think instruction set is just the list of instructions and what they do, while architecture is the more broad spec for the cpu family
- I dont understand the question? pointers are just numbers? You can do arithmetic with numbers?
- I barely remember parsing algorithm theory from college. I know context free grammars can be parsed by a (not necesseraly deterministic) pushdown automata, which corresponds roughly to a bottom up parser. I think intuitively the top down parser needs to guess what the shape of the AST is after inspecting the first few tokens. Problem is, on a complicated language, it needs to look at more tokens to make this decision. A bottom up parser can make smaller elements with a few tokens, and build up the larger structure as it gets more info.
- Because ints are (i think nowadays) 32bits long, and pointers to int are required by the CPU to be at a 4 byte
alignment to be efficiently loaded, (on some CPUs you get an exception on unaligned reads) so after the first byte taken up by bar, the compiler is forced to add 3 bytes of padding to fit baz.- Because typeof('c') is an int?
- I dont understand the question either. Function pointers? Like passing a callback to something? That can change the flow of code dynamically at runtime.
- I frankly dont, I usually stay away from weird struct initialization syntax
- I dont know what decay means. (NOTE: After looking up what decay means, the answer is obvious, casting the multidimensional array to a pointer makes it lose the information about the dimensionality and flattens the array into a flat sequence) (I have never seen the term 'decay' used like this before lol)
- I guess PIDs? Shell scripts can use lots of PIDs because they constantly invoke new programs. Linux uses 16 bit pids so you have 64k max.
>>3027(deleted)
Not everything can be calculated by the RIP actually.
Its possible that you have data structures in .rodata that contain pointers to other things. For them to work properly there needs to be an initialisation code that sets them during execution, the offsets are located in sections like .rela.dyn
I know this because i had to write this manually on hobby kernel code xD
>>3028
SInce you understand PI code take a look at this bug I encountered a while ago:
how to compile with clang19 or gcc13:cc -fPIC
int *p = (void *)0xDEADBEEF;
int main(void) {void *q;q = p + 1;asm("" : : "m"(p), "m"(q) : "memory"); // don't optimize p and q out}
Disassembled code:4: movq (%rip), %raxb: movq (%rax), %raxe: addq $4, %rax12: movq %rax, -0x8(%rbp)
Notice how the assembly code would be OK if line B were removed. I posted it on the other site as well but it got buried under all the shitposting.
>>3037
i dont think thats a bug
the instruction in 4 seems to be replaced with
lea XXX(%rip), (%rax)
after linking
notice that between 4 and B theres a large space, of 7 bytes, thats a place for the linker to fill in the correct offset
indeed after compiling with cc -FPIC -c main.c
doing a readelf -r main.o one has a R_X86_64_REX_GOTP relocation pointing 3 bytes a ahead of movq (%rip), %rax
>>3008
The Cult of Kek is one of my favourite things that has ever happened in online culture, and I say this as someone who opposes maybe 70-80% of what /pol/ stands for.