This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
John Fine wrote:I don't understand your objection. I certainly am worried this construct will stop working in future versions of gcc (though not for the reason you described). I'm getting pretty confident that it works reliably for gcc 4.3.2 because it has fixed every case where I have needed it.
Working code:
union { DAT* pp; std::size_t dummy; } no_strict_alias;
no_strict_alias.pp =foo();
reinterpret_cast<DAT_PTR*>(&no_strict_alias.pp)->bar(x);
No, this isn't guaranteed to work. Your data must be *declared* as union no_strict_alias. Casting to a pointer to union no_strict_alias isn't the same unless the only way you ever access your data is via that cast.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |