zaphoyd/websocketpp — pull request #95 by blindmatrix (2012-03-15 19:21:37+00:00)
Title: Fixed compile-time warnings

Fixed compile-time warnings on Linux under x86_64 (Kubuntu 11.10).

Haven't been able to test them more then that the examples seem to work as intended.

**What have been done?**

Strict aliasing requires that no variable is referred to by more then one type of pointers that differ in more then sign-ness, const-ness or volatile-ness (unsigned int* and const int* is okay, but not int* and double*).

There exists an exception, you can always refer any variable as an char *, that means that you can assign ints and stuff to data-blobs by simply mem-copying a char* variant of that variable, but you can not read the value back by converting the blob to, say, an int*. To be "correct" you'll instead have to refer to the target int as an char* and mem-copy it that way.

```c++
char blob[100] = {...};
uint_16* as_uint = blob + offset; // incorrect
uint_16 target = *as_uint;
```

Instead you'll have to do

```c++
char blob[100] = {...};
uint_16 target;
memcpy((char*)target, blob + offset, sizeof(target));
```

And then, hopefully, the compiler will be smart enough to do this in an efficient matter ;)

***Sorry*** about the lecture, that's just the way I am ;)