I get this warning. I would like to define the behavior, but I would like to keep this code as it is. When can I break the alias rules?
warning: dereferenced type-guard pointer violates strict anti-aliasing rules [-Wstrict-aliasing]
A string is my own string, which is a POD. This code is called from C. S can be int. String pretty much struct String { RealString*s; } struct String { RealString*s; } , but boilerplate and helper functions. I am making a static statement to make sure String is a module, is 4 bytes and int is 4 bytes. I also wrote a statement that checks if all pointers are> = NotAPtr. Its in my new overload / malloc. I can put this statement in String if you suggest
Given the rules that I follow (basically, this line is a container and always the same size as int) would it be nice if I broke the rules of aliases? Is this one of the few times he violates this right?
void func(String s) { auto v=*(unsigned int*)&s; myassert(v); if(v < NotAPtr) {
user34537
source share