# \[RFC\] Warning suppression policy

**URL:** <https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676>\
**Category:** Flang\
**Created:** [February 3, 2026, 12:41pm UTC](https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676 "2026-02-03T12:41:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Meinersbur](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/meinersbur/32/27423_2.png) [@Meinersbur](https://discourse.llvm.org/u/Meinersbur)\
**Post date:** [February 3, 2026, 12:41pm UTC](https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676/1 "2026-02-03T12:41:05Z")

</div>

[[flang-rt][build] Disable two build-time warning of '-Wuninitialized' from g++ compiler by zjlcd · Pull Request #174918 · llvm/llvm-project · GitHub](https://github.com/llvm/llvm-project/pull/174918) (and some other related PRs) try to silence a false gcc warning by adding pragmas around the function where gcc reports an unitialized variable:

```diff
+#if defined( __GNUC__ )
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wuninitialized"
+#endif

static Type Value() {
  ...
}

+if defined( __GNUC__ )
+#pragma GCC diagnostic pop
+#endif

```

where an alternative is to just zero-initialize (instead-of default-initialize) the variable:

```diff
     constexpr std::size_t alignment =
         std::max(alignof(Type), alignof(std::uint64_t));
- alignas(alignment) char data[sizeof(Type)];
+ alignas(alignment) char data[sizeof(Type)]{};

```

I think the former is the more probablematic trade-off:

1. Many more lines
2. Applies to a region of code, not to the specific occurance of the warning
3. Does not tell why the pragma is there (a comment could solve that)
4. Potentially also silences other, legitimate warnings
5. Also silences Clang warnings, even though it does not report this false positive (see [Compiler Explorer](https://godbolt.org/z/GTMEeq8cd)). This could be solved with another `#if defined( __clang__ )` condition as done [elsewhere](https://github.com/llvm/llvm-project/blob/main/flang-rt/include/flang-rt/runtime/terminator.h#L45-L47).
6. The additional zero-initialization is removed by any compiler with even the lowest level of optimizations enabled (see [Compiler Explorer](https://godbolt.org/z/6sE6hc3qG)).

My question is, should we still introduce such pragmas?

* * *

Not related to the question, but to the PR: I think the gcc warning shows a different issue, namely using `reinterpret_cast` to access memory using two different non-char types (here: `std::uint64_t` and `__float128`) is [undefined behavior](https://en.cppreference.com/w/cpp/language/reinterpret_cast.html#Type_aliasing), since the compiler can assume that the two accesses do not alias:

> This rule enables type-based alias analysis, in which a compiler assumes that the value read through a glvalue of one type is not modified by a write to a glvalue of a different type

 ![image](https://us1.discourse-cdn.com/flex021/uploads/llvm/original/3X/d/2/d23deac638a5b9800cb1e8059d70edf3bc89bdfc.png)

---

<div class="post-metadata">

**Author:** ![tmj](https://avatars.discourse-cdn.com/v4/letter/t/ed655f/32.png) [@tmj](https://discourse.llvm.org/u/tmj)\
**Post date:** [February 3, 2026, 2:11pm UTC](https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676/2 "2026-02-03T14:11:56Z")

</div>

I’d say zero initialize.

When/How would we know the issue with GNU has been addressed and the WARs can be removed without the bogus message returning?

---

<div class="post-metadata">

**Author:** ![tarunprabhu](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/tarunprabhu/32/14862_2.png) [@tarunprabhu](https://discourse.llvm.org/u/tarunprabhu)\
**Post date:** [February 3, 2026, 3:31pm UTC](https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676/3 "2026-02-03T15:31:10Z")

</div>

Do we know why pragmas were used in the first place? Was there a concern that the zero-initialization would not be optimized away?

---

<div class="post-metadata">

**Author:** ![mehdi\_amini](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/mehdi_amini/32/25595_2.png) [@mehdi\_amini](https://discourse.llvm.org/u/mehdi_amini)\
**Post date:** [February 3, 2026, 3:49pm UTC](https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676/4 "2026-02-03T15:49:58Z")

</div>

In general I rather disable GCC warnings in CMake when they prove to have false positives:

1. this preserves clang warnings, which is the most important for the project.
2. this can be done on specific GCC versions so that when GCC improves we can enable the warning again.

Here is how it looks in practice: [llvm-project/mlir/CMakeLists.txt at main · llvm/llvm-project · GitHub](https://github.com/llvm/llvm-project/blob/main/mlir/CMakeLists.txt#L98-L110)

---

<div class="post-metadata">

**Author:** ![Meinersbur](https://sea1.discourse-cdn.com/flex021/user_avatar/discourse.llvm.org/meinersbur/32/27423_2.png) [@Meinersbur](https://discourse.llvm.org/u/Meinersbur)\
**Post date:** [February 3, 2026, 6:49pm UTC](https://discourse.llvm.org/t/rfc-warning-suppression-policy/89676/5 "2026-02-03T18:49:20Z")

</div>

> [@tarunprabhu](#):
>
> Was there a concern that the zero-initialization would not be optimized away?

> <https://github.com/llvm/llvm-project/pull/173955#discussion_r2668910158>
>
> Don't initialize \`ub\[\]\` -- that would be a nontrivial amount of needless overhea…d.

To be fair, this is a zero-initialization of 120 bytes
