mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:17:34 +00:00
Meta: Disable -Wmaybe-uninitialized
It's prone to finding "technically uninitialized but can never happen" cases, particularly in Optional<T> and Variant<Ts...>. The general case seems to be that it cannot infer the dependency between Variant's index (or Optional's boolean state) and a particular alternative (or Optional's buffer) being untouched. So it can flag cases like this: ```c++ if (index == StaticIndexForF) new (new_buffer) F(move(*bit_cast<F*>(old_buffer))); ``` The code in that branch can _technically_ make a partially initialized `F`, but that path can never be taken since the buffer holding an object of type `F` and the condition being true are correlated, and so will never be taken _unless_ the buffer holds an object of type `F`. This commit also removed the various 'diagnostic ignored' pragmas used to work around this warning, as they no longer do anything.
This commit is contained in:
parent
45710d0724
commit
50349de38c
5 changed files with 1 additions and 20 deletions
|
@ -118,10 +118,7 @@ int main(int argc, char** argv)
|
|||
if (!uninitialized_memory)
|
||||
return Crash::Failure::UnexpectedError;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
[[maybe_unused]] volatile auto x = uninitialized_memory[0][0];
|
||||
#pragma GCC diagnostic pop
|
||||
return Crash::Failure::DidNotCrash;
|
||||
}).run(run_type);
|
||||
}
|
||||
|
@ -144,10 +141,7 @@ int main(int argc, char** argv)
|
|||
if (!uninitialized_memory)
|
||||
return Crash::Failure::UnexpectedError;
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
uninitialized_memory[4][0] = 1;
|
||||
#pragma GCC diagnostic pop
|
||||
return Crash::Failure::DidNotCrash;
|
||||
}).run(run_type);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue