Hacker News new | past | comments | ask | show | jobs | submit login

>You should file a bug report. This should in fact, work, and did, in fact, work, when i stopped working on it.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=14319 (12 years ago, status: suspended)




Err, this is a completely different case.

This is the union case you can't make work right all the time, and is actually two DR's, as the bug says. This is a case where the standard is completely broken (and will likely never be fixed)

The viewpoint of committee members i spoke with is that explicitly visible union accesses should be required to get the right answer here, because anything else is insanity.

I could place your two memory accesses in a union, in a different translation unit, and pass it to this function, and you would never have any reason to know they alias, because it looks like i handed you two struct pointers. IE imagine the function and main were in two different files, one of which had the union, and other other did not.

So either the compiler assumes that literally all memory, everywhere, aliases, forever (despite any other rules that the standard says exist, which directly contradict this), or we require programmers to make explicit union accesses (or your answers change depending on how much code the compiler can see, and whether it does whole program optimization or not or ....)

Like I said, this is a case where the standard is truly broken, and the best you can do is try to build consensus about what to do.

Note also the bug was suspended to figure out what the language was supposed to mean here. Nobody said it was not a bug, they said "no idea what supposed to happen here". The committee punted (contrary to the last comment, they didn't really resolve the question), so it's never been worked on.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: