Don't just let your compiler boss you around, you're better than that.

*suddenly switches to a more sinister tone*
Just write naked functions for a while and let it see how much you don't need it.

@loganer Well, this is kinda compiler-dependent but at least on gcc, there is `__attribute__((naked))`

@mage_of_dragons actually this could be useful for me.

later of course.

@mage_of_dragons assuming of course that the compiler wont just opti-fuck the code away of course... I will need to do experiments later.

@loganer it tends to do that yeah x3

There's usually a volatile or some constraint you can do though

@mage_of_dragons I really don't want to jump through all these whoops to get the compiler to just compile what I wrote, it's kind of really silly how this came about.

you'd think these optimizations would be opt-in but nope ... because supposedly the compiler people know better (they really don't but they like to think they do.)

@loganer Wdym, they are usually opt-in. And (not a compiler dragon but) compiler people do usually know better since most code doesn't require inline assembly, precise struct alignment, non-cached writes, parallelism etc., which is in my experience the only time I had problems with them.

@mage_of_dragons

most of the basic optimizations are opt-out actually.
to do debugging for instance you have to pass in -O0 to the commandline but even that doesn't turn off all the optimization stuff.

the existence of volatile as a keyword demonstrates this as well, this keyword would not need to exist if the optimizations were opt-in.

@loganer Well yeah, if the compiler were to make something like struct alignment opt-in, it'd do a lot more harm than good.

> the existence of volatile as a keyword demonstrates this as well, this keyword would not need to exist if the optimizations were opt-in.

I don't see how its existence makes optimizations opt-in. It's there that *if* some optimization that would cause it to break were enabled, the compiler doesn't apply it.

@mage_of_dragons it's existence proves that it's opt-out and it would not need to exist if the optimization was opt-in as the optimization would be selected on the commmandline during compile time.

I just want the compiler to take the input code and do absolutely nothing to it and translate it directly into assemble... is that too hard?

@loganer Say I have
```c
#include <stdio.h>
void test() {
int test = 32;
printf("%d", test);
}
```

The memory write will get executed with no opts, but will be optimized to use a register with as low as -O1.

If I make it volatile, the memory write is preserved even with -O3. This is what volatile is for, to mark the places that have side effects the compiler might not understand, *should* the program ever be compiled with optimizations. Without opts, volatile may as well be ignored.

@mage_of_dragons

let me demonstrate the real problem here...

```c
void test() {
int test = 0;
if(test){
printf("%d", test);
}
}
```

@loganer dead code removal is the real problem?

@mage_of_dragons

it is part of the problem, yes, and the most easily demonstrable part...
but it is not the whole problem, which is a bit more broader.

@loganer Could you explain further? I'm at the end of my compiler knowledge x3