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

            Bug ID: 100083
           Summary: combining `-O3` and `-fPIC` causes "used
                    uninitialized" error
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yichen.yan at inf dot ethz.ch
  Target Milestone: ---

g++ reports "used uninitialized" error only with -O3 and -fPIC.

Sorry for the unreadability, This case is reduced by creduce, from some STL
code.

root@amdsuplus1:/test# g++ -Werror=uninitialized -fPIC -o /dev/null -S test.ii
root@amdsuplus1:/test# g++ -Werror=uninitialized -O3 -o /dev/null -S test.ii
root@amdsuplus1:/test# g++ -Werror=uninitialized -O3 -fPIC -o /dev/null -S
test.ii
test.ii: In member function 'void u::v()':
test.ii:24:20: error: '<anonymous>' is used uninitialized in this function
[-Werror=uninitialized]
   int t() { return q<int>(*this).r(); }
                    ^~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
root@amdsuplus1:/test# cat test.ii
// g++ -Werror=uninitialized -O3 -fPIC -o /dev/null -S test.ii

template <int a> struct b { static const int aa = a; };
struct c {
  static b<0> d();
};
template <bool, bool, class...> struct f;
template <class e, bool g, class... h> struct f<false, g, e, h...> : b<0> {};
struct i : f<decltype(c::d())::aa, b<0>::aa, int> {};
void j(long) {}
class k;
template <class, class = c> class l;
struct n {
  typedef b<0> m;
};
template <class> struct q {
  int r() { return ah; }
  int ah;
  q(int) {}
};
class s : q<int>, q<k> {
public:
  template <class an, class ao> s(an, ao) : q<int>(0), q<k>(ao()) {}
  int t() { return q<int>(*this).r(); }
};
template <class> class ar {
public:
  s at;
  ar() noexcept(i::aa);
  ~ar();
};
template <class e> ar<e>::ar() noexcept(i::aa) : at(nullptr, int()) {}
template <class e> ar<e>::~ar() {
  long o = at.t();
  j(o);
}
template <class, class> class l : ar<int> {
public:
  l() {}
  l &operator=(l &&) noexcept(b<n::m::aa>::aa);
};
template <class e, class az>
l<e, az> &l<e, az>::operator=(l &&) noexcept(b<n::m::aa>::aa) {
  return *this;
}
struct H {
  l<int> p;
};
class u {
  void v();
  H au;
};
void u::v() { au = {}; }
  • [Bug c++/100083] New: combining... yichen.yan at inf dot ethz.ch via Gcc-bugs

Reply via email to