https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66110
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jsm28 at gcc dot gnu.org --- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Kevin OConnor from comment #8) > Thanks! I can confirm the latest trunk performs the desired optimization. > > However, this test case still isn't fully optimized: > > void f2(struct s1 *ps1, uint8_t *pi8) > { > ps1->f1 = 3; > *pi8 = 8; > ps1->f1 += 2; > } > > That is, an "uint8_t*" still aliases with every other type. The "struct" > optimization is more important for my usage, but it is unfortunate that > uint8_t*/int8_t* are pessimized. (In particular, there does not appear to > be any way to declare a pointer to an 8 bit integer that doesn't alias every > other type.) > > I can open a separate bugzilla entry on the above. Well, so it ultimiatively boils down to GCC defining #define __UINT8_TYPE__ unsigned char and that being a character type. I'm not sure whether the C or C++ standards mandate that uint8_t be a 'character type' as far as type-based aliasing goes but I would expect that user-code may rely on that property. So yes, there would be no 1-byte type that doesn't get alias-set zero. Well - you could use struct byte { uint8_t b; }; and make sure to use aggregate assignments everywhere, only ever extracting the actual value from temporary aggregates...