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

Time to Test Your Compiler

Name: Anonymous 2014-04-30 9:59

void foo() {}
void bar() {}
void main() {
if ((void*)foo < (void*)bar) {
printf("sound compiler! preserves ordering.\n");
} else {
printf("your gaypiler sucks balls and doesn't respect memory layout\n");
}
}

Name: Anonymous 2014-04-30 11:38

Dear >>1,

You suck.

Why should C compiler not order functions? It should put frequently used functions together and ignore the ordering in code.

Name: Anonymous 2014-04-30 11:41

struct { char i; int y; char j }; does your cp,mpierl sucK this?

Name: Anonymous 2014-04-30 11:48

>>2

Being the Portable Assemblerâ„¢, C/C++ shouldn't re-order anything, NASM and FASM don't.

Name: Anonymous 2014-04-30 12:09

>>1

#include <stdio.h> /* puts */
#include <stdlib.h> /* exit success */

void foo(void) {}
void bar(void) {}
typedef void (*anus)(void);
int
main (void)
{
if ((anus)foo != (anus)bar)
puts ("your compiler sucks");
else
puts ("your compiler sucks less");
return EXIT_SUCCESS;
}

Name: Anonymous 2014-04-30 12:30

>>5
EXIT_SUCCESS
shiggy diggy

Name: Anonymous 2014-04-30 14:17

Wow, you guys are totally retarded

Name: Anonymous 2014-04-30 15:06

[1 of 1] Compiling Main ( temp.hs, temp.o )

temp.hs:4:1: parse error on input `if'

Name: Anonymous 2014-04-30 15:31

>>1,4,5
Worst kind of retard. They think they know low level but the performance of their program will be shit.

Name: Anonymous 2014-04-30 16:02

>>9
Worst kind of retard. He thinks low level programming has anything to do with performance.

Name: Anonymous 2014-04-30 16:18

>>7,9
you're mom lol
what's the problem?

Name: Anonymous 2014-04-30 16:20

>>10
Worst kind of retard. He thinks C/C++ is low level and gives more performance than GPU.

Name: Anonymous 2014-04-30 18:30

>>1,4
Read the standard, learn what undefined behavior is, and stop spouting garbage.

Name: Anonymous 2014-04-30 20:43

>>13
We pick the compiler with the best undefined behavior!

Name: Anonymous 2014-04-30 21:43

Name: Anonymous 2014-04-30 22:33

>>15
ohshit

Name: Anonymous 2014-05-01 6:06

>>1,4,5
I cannot think of any situation where it would strongly benefit you to do this sort of ordering by hand. If it really matters, most compilers will allow you to declare an output section for each function so you can set the ordering at link time. You'd probably be better of just using assembly for the entire hot path though.

IHBT

>>2
Profile guided optimizers do exactly this.

>>14
You can't rely on this behavior if your toolchain re-orders functions based on input from a profile guided optimizer, or if it generates a separate segment for each function (for link time dead code elimination, etc). If your compiler doesn't support either of these, it's crap.

Name: Anonymous 2014-05-01 6:10

>>6
Too bad da standard doesn't permit you to assume 0 for success and 1 for failure. Does anyone know of a platform where this isn't the case? (Non-hosted environments where returning from main crashes your program don't count.)

Name: Anonymous 2014-05-01 7:11

>>17

I cannot think of any situation where it would strongly benefit you to do this sort of ordering by hand.
http://en.wikipedia.org/wiki/Order_theory

order of thing in memory can be used to encode all kinds of information.

Name: Anonymous 2014-05-01 13:14

>>18
the standard says that 0 and EXIT_SUCCESS is success but only EXIT_FAILURE is failure

Does anyone know of a platform where this isn't the case?
QNX I think

Name: Anonymous 2014-05-02 0:02

>>19
That doesn't address >>17's ``strongly'', since I can't (off the top of my head) think of any situation in which you would want in-memory ordering to matter AND in which there's no way to do it in a more portable manner, barring IOCCC-level wanking. Can you give a concrete example of a problem in which 1) you need to encode information by ordering, 2) you cannot rely on an optimizer to do so, and 3) there is not another (relatively simple) method of encoding this information?

Name: Anonymous 2014-05-05 14:28


#include <stdio.h>

int main() {
if ((int)-1 >> 1 == -1) {
printf("sound compiler! knows people use shift to div their ints.\n");
} else {
printf("your GCC can't even div a number by two! use MSVC\n");
}
return -123;
}

Name: Anonymous 2014-05-05 14:32

>>22

s/main/wmain/

Name: Anonymous 2014-05-05 14:37

>>21

Can you give a concrete example of a problem in which 1) you need to encode information by ordering, 2) you cannot rely on an optimizer to do so, and 3) there is not another (relatively simple) method of encoding this information?
Let's say we have a number of memory pools, used to do BIBOP allocation. Each pool has corresponding handler, which hardcodes stuff like memcpy and memcmp for its corresponding pool size. We want these pool handlers to be ordered in memory according their pool sizes, so that determining if object can be copied from one pool to the other would require just handler pointer comparison, instead of calling their length functions and comparing results.

Name: Anonymous 2014-05-05 14:40

>>21

there is not another (relatively simple) method of encoding this information?
Yes. You can store 4-byte length to allocate 1-byte object, wasting 4 bytes per allocation (thank you, dear GCC!).

Name: Anonymous 2014-05-06 2:24

>>24
You can trivially accomplish that without resorting to implementation-defined behavior by dynamically allocating all the pools from the same array of pages. In practice you must do that anyway since portable code can't make assumptions about the size of a page.

Name: Anonymous 2014-05-06 5:09

in this itt thread retrarded bitfucker leaks abstractions all over the place.

Name: Anonymous 2014-05-06 6:36

>>26
You can trivially accomplish that without resorting to implementation-defined behavior by dynamically allocating all the pools from the same array of pages.
How does that give you order?

In practice you must do that anyway since portable code can't make assumptions about the size of a page.
portable code != efficient code. In general portable code is order of magnitude less efficient than native code, using full capability of x86 CPUs.

Name: Anonymous 2014-05-06 6:46

>>28
What order of magnitude is that?

Name: Anonymous 2014-05-06 7:22

Name: Anonymous 2014-05-06 15:52

>>28
An array element at a lower index is guaranteed to have an address that is lower than an array element at a higher index. So if you allocate all the pools from the same array, total ordering is guaranteed.

>>30
I don't know what you are trying to say here, and I suspect you don't either. You are aware that page boundaries and cache line boundaries are different, right? Most compilers will try to put things on a cache line boundary if asked; in practice however this can hurt more than help because the padding required to ensure alignment reduces the total cache utilization.

Name: Anonymous 2014-05-07 8:24

>>31

An array element at a lower index is guaranteed to have an address that is lower than an array element at a higher index. So if you allocate all the pools from the same array, total ordering is guaranteed.
You don't know in advance how many pools you will need or their size. A pool have size of say 512 bytes and when it becomes full, you replace it with an empty one, while older get garbage collected.

Name: Anonymous 2014-05-07 8:26

>>31

in practice however this can hurt more than help because the padding required to ensure alignment reduces the total cache utilization.
That is why a you have to manually optimize everything down to assembly. Otherwise you code will be inefficient.

Name: Anonymous 2014-05-07 19:10

This bullshit wouldn't have happened if you stopped programming for iOS earlier, you maggot dickface.

Name: Anonymous 2014-05-07 19:30


public class JavaSevenIsTheFuture {
public static void foo() { }
public static void bar() { }

public static void main(String args[]) {
if (JavaSevenIsTheFuture::foo < JavaSevenIsTheFuture::bar) {
System.out.println("Gay, doesn't even compile.");
}
}
}

Name: Anonymous 2014-05-08 0:44

>>32
And your proposed solution to this is... what, exactly? Encoding information about the pool size in the pool copy code entry point addresses doesn't gain anything over just storing the length of the pool. In the former case you must store a pointer to the handler somewhere.

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