[Bug c++/68281] '&&' is checked in reverse and reads an uninitialized value

jistone at redhat dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 11 00:36:00 GMT 2015


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

--- Comment #2 from Josh Stone <jistone at redhat dot com> ---
This may also be significant:

bool
base_query::get_number_param(literal_map_t const & params,
                             interned_string k, long & v)
{
  int64_t value;
  bool present = derived_probe_builder::get_param (params, k, value);
  v = (long) value;
  return present;
}

We're entering here with v uninit, and clearly value is uninit.  If get_param()
returns false, then value will still be uninit when it's copied to v.

If I just make that assignment conditional:
  if (present) v = (long) value;
then the code for line 1002's '&&' no longer reverses the checks.

Does that assignment trigger undefined behavior?  Or is it just coincidence?


More information about the Gcc-bugs mailing list