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

            Bug ID: 109559
           Summary: Unexpected -Wmaybe-uninitialized warning when inlining
                    with system header
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mpolacek at gcc dot gnu.org
  Target Milestone: ---

The following testcase (the directives simulate a system header) triggers a
-Wmaybe-uninitialized warning:

$ xg++ -c un.cc -Wall -O2
In member function ‘int function1::swap(function1)’,
    inlined from ‘int function::operator=(Functor) [with Functor =
FilonIntegral::integrate() const::<lambda()>]’ at :8:56,
    inlined from ‘double FilonIntegral::integrate() const’ at :9:6:
:5:49: warning: ‘f1’ may be used uninitialized [-Wmaybe-uninitialized]
: In member function ‘double FilonIntegral::integrate() const’:
:1:3: note: by argument 1 of type ‘const function_base*’ to ‘int
function_base::has_trivial_copy_and_destroy() const’ declared here
:8:12: note: ‘f1’ declared here

$ xg++ -c un.cc -Wall -O2 -fno-inline
# nothing

# 0 "" 3
struct function_base {
  has_trivial_copy_and_destroy() const;
  int functor;
};
struct function1 : function_base {
  swap(function1) { has_trivial_copy_and_destroy(); }
};
struct function : function1 {
  template <typename Functor> operator=(Functor) { swap(*this); }
};
# 4 ""
struct FilonIntegral {
  double integrate() const;
};
double FilonIntegral::integrate() const {
  function f1;
  f1 = [] {};
  return 0;
}

Reply via email to