https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122506

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Nuno Lopes from comment #2)
> Here are two examples of constructor calls that touch uninitialized memory:
> 
> std::vector<bool> f() {
>   return {1, false};
> }
> 
> std::vector<bool> g() {
>   return {true, false};
> }

I still don't see where that happens.

> 
> >> If the access goes through the operator[], it loads uninitialized memory
> >> first, and then masks it.
> >
> > Which access?
> 
> In __fill_bvector_n.

How does anything in __fill_bvector_n use operator[]?

It's using __p[__n] on a pointer, and assigning to it immediately which does
not load anything and does not mask anything. And that only happens during
constant evaluation, so if it was using an indeterminate value, it would be
diagnosed by the compiler.

During runtime, it uses memset to fill the memory. That obviously doesn't use
operator[] either, and doesn't load anything.

Reply via email to