История изменений
Исправление hateyoufeel, (текущая версия) :
То, что его сделали дефолтно-включённым с -O2 - это диверсия.
Хуже того, он дефолтно-включён даже с -O0. Это вообще часть языка:
An object shall have its stored value accessed only by an lvalue that has one of the following types:
the declared type of the object,
a qualified version of the declared type of the object,
a type that is the signed or unsigned type corresponding to the
declared type of the object,
a type that is the signed or unsigned type corresponding to a
qualified version of the declared type of the object,
an aggregate or union type that includes one of the aforementioned
types among its members (including, recursively, a member of a
subaggregate or contained union), or
a character type.
Цитата прямо из C89, т.е. в Си это было буквально вообще всегда. Просто сишные говнокодеры не могут не перекастовать через пятнадцать указателей и три залупы всё подряд, поэтому приходится это выключать.
Другой вопрос, что uint8_t – алиас на unsigned char, поэтому strict aliasing здесь вполне удовлетворён. ТС, у тебя нет UB, расслабь булки.
Исходная версия hateyoufeel, :
То, что его сделали дефолтно-включённым с -O2 - это диверсия.
Хуже того, он дефолтно-включён даже с -O0. Это вообще часть языка:
An object shall have its stored value accessed only by an lvalue that has one of the following types:
the declared type of the object,
a qualified version of the declared type of the object,
a type that is the signed or unsigned type corresponding to the
declared type of the object,
a type that is the signed or unsigned type corresponding to a
qualified version of the declared type of the object,
an aggregate or union type that includes one of the aforementioned
types among its members (including, recursively, a member of a
subaggregate or contained union), or
a character type.
Цитата прямо из C89, т.е. в Си это было буквально вообще всегда.
Другой вопрос, что uint8_t – алиас на unsigned char, поэтому strict aliasing здесь вполне удовлетворён. ТС, у тебя нет UB, расслабь булки.