Can those lines of code be optimized away?

```
int *ptr = (int *)0x1234;
*ptr = 2;
/* no further code in the scope uses ptr */

```

Can I be sure that for any decent compiler and with any level of optimization, this code will be executed?

Testing it with `-S` flag on two different compilers (`gcc` and `gcc-arm-none-eabi`) shows me this code is not optimized away. But I'm looking for a certain assurance or guideline regarding this specific code. 

**Solved *(I believe):*** Accepted answer given by Jonathan Mee, from [Wikipedia - Alias analysis](https://en.wikipedia.org/wiki/Alias_analysis)

> 
> ...if it is not known if p and q alias or not, then no optimizations can be performed and the whole of the code must be executed
> 
> 
> 

To my understanding, `p` can be referred in this example to my `ptr` which points to `0x1234`, and `q` can actually be considered to any type of reference to this address on the program.