Oh, it would be a warning with -Wcast-qual, ok, got it. --David On Fri, Apr 7, 2017 at 8:21 AM, David Grayson <davidegray...@gmail.com> wrote:
> > type1 *foo(const type1 *my_const_ptr) > > { > > union { > > type1 *t1; > > const type1 *ct1; > > } v; > > v.ct1 = my_const_ptr; > > return v.t1; > > } > > Yes, that is sad, and it seems like just a matter of time before a C++ > compiler looks at the code above and reasons that the write to ct1 can be > optimized away because there is no code that ever reads from ct1. Thus the > read from t1 will be recognized as undefined behavior (probably called a > poison value in LLVM) and anything could happen. > > What was the problem with Mateusz's patch? I think people are implying it > results in compiler warnings, but I thought casting a pointer to a pointer > usually doesn't give any warnings. > > --David > > On Fri, Apr 7, 2017 at 4:33 AM, Norbert Pfeiler < > norbert.pfeiler+mingw-...@gmail.com> wrote: > >> That’s a kinda sad stance for a compiler support project, don’t you think? >> >> Best, Norbert. >> >> Liu Hao <lh_mo...@126.com> schrieb am Fr., 7. Apr. 2017 um 05:48 Uhr: >> >> > On 2017/4/7 8:11, Norbert Pfeiler wrote: >> > > Wasn’t LH_Mouse’s point that even if the warning is explicitly turned >> on >> > it >> > > wouldn’t be shown to the user? >> > > >> > > The situation for unions is different in C and C++: (I don’t think >> that >> > > it’s just about constness changes anything) >> > > http://stackoverflow.com/questions/11373203 >> > Nice link. Nevertheless, I don't think most people care about UB unless >> > UB bites them (that is, unless UB refuses to work silently). XD >> > >> > -- >> > Best regards, >> > LH_Mouse >> > >> > >> > >> > ------------------------------------------------------------ >> ------------------ >> > Check out the vibrant tech community on one of the world's most >> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> > _______________________________________________ >> > Mingw-w64-public mailing list >> > Mingw-w64-public@lists.sourceforge.net >> > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public >> > >> ------------------------------------------------------------ >> ------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> Mingw-w64-public mailing list >> Mingw-w64-public@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public >> > > ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public