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

What will this output?

Name: Anonymous 2016-06-19 12:21

What will this program output?
Good luck, you'll need it!

#include <iostream>
using namespace std;

int main() {
class c {
public:
c() {
void f();
f();
}
};

c my_c();
}

void f() {
cout << "VALID C++" << endl;
}


The answer is absolutely nothing because c my_c(); is a fucking function declaration.

Name: Anonymous 2016-10-28 15:54

>>80
The standard allows it to be.
It doesn't require it to be. So any code which depends on GC cannot be said to be standard-conforming.

You assume many things.
It's a valid assumption because we're talking about algorithms, not implementations. So it's assumed the compiler generates the "most literal interpretation" of the source code.

Its UB
Again, according to "most literal interpretation", a null pointer would be interpreted as pointing to a non-valid memory address. Meaning that assignment would cause a segfault on a system with memory protection. Not all implementations may exhibit this behavior, but again we are talking about algorithms, not implementations. In any case, we could eliminate this issue by revising the program to

int main(void) {
unsigned char *ptr;
while(1) {
ptr = malloc(sizeof(char));
if(ptr) {
*ptr = 255;
} else return 1;
}
return 0;
}


Which means, assuming no optimization, and no GC, this program will exit with an exit code of 1 on any real computer, while on a Turing machine it should keep looping forever (since having unbounded memory means there is really no logical reason for a call to malloc() to fail).

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