[Bug middle-end/78044] -Wmaybe-uninitialized and -O2: false positive with boost::optional
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Oct 20 08:16:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78044
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Well. someFunction () is optimized down to just
void someFunction() ()
{
int aOptional$4;
struct C D.2560;
struct C D.2555;
void * _4;
<bb 2>:
C::operator mpl_::B (&D.2555);
D.2555 ={v} {CLOBBER};
_4 = operator new (8);
C::operator mpl_::B (&D.2560);
<bb 3>:
D.2560 ={v} {CLOBBER};
MEM[(int *)_4 + 4B] = aOptional$4_2(D);
return;
<L0>:
operator delete (_4, 8);
resx 3
so unless C::operator mpl_::B (&D.2560); always throws we store
aOptional$4_2(D)
(uninitialized) to MEM[(int *)_4 + 4B]. The warning itself is a bit misleading
I guess.
Thus
int __trans_tmp_1 = p1.get_impl ();
new (m_storage.address ()) int(__trans_tmp_1);
and
int
get_impl ()
{
union
{
void *ap_pvoid;
int *as_ptype;
} caster{m_storage.address ()};
get_impl___trans_tmp_3 = *caster.as_ptype;
int __trans_tmp_2 = get_impl___trans_tmp_3;
B __trans_tmp_4 = C ();
return __trans_tmp_2;
}
doesn't cover up the fact that m_storage is not initialized.
This might be an artifact of the testcase reduction of course.
More information about the Gcc-bugs
mailing list