[Bug bootstrap/92762] hash_table::empty_slow invokes assignment on invalid objects

2019-12-09 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92762

--- Comment #4 from Martin Sebor  ---
Author: msebor
Date: Mon Dec  9 20:54:11 2019
New Revision: 279139

URL: https://gcc.gnu.org/viewcvs?rev=279139=gcc=rev
Log:
PR middle-end/92761 - hash_table::expand invokes assignment on invalid objects
PR middle-end/92762 - hash_table::empty_slow invokes assignment on invalid
objects

gcc/ChangeLog:

PR middle-end/92761
PR middle-end/92762
* hash-map-tests.c (test_map_of_type_with_ctor_and_dtor): Tighten
up tests.
* hash-table.h (hash_table::expand): Use placement new to copy
construct objects in uninitialized storage.
(hash_table::empty_slow): Avoid invoking copy assignment on
uninitialized objects.


Modified:
trunk/gcc/ChangeLog
trunk/gcc/hash-map-tests.c
trunk/gcc/hash-table.h

[Bug bootstrap/92762] hash_table::empty_slow invokes assignment on invalid objects

2019-12-03 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92762

--- Comment #3 from Martin Sebor  ---
It looks to me like the whole else block with the BROKEN_VALUE_INITIALIZATION
guard is incorrect.  The following test case aborts:

typedef int_hash IntHash;

hash_map > x;

static void test_hash_table ()
{
  for (int i = 1; i != 32; ++i)
x.put (i, i);

  x.empty ();

  gcc_assert (!x.get (0));   << abort here
}

internal compiler error: in test_hash_table, at cp/parser.c:43483
0xaea59d test_hash_table
/src/gcc/61339/gcc/cp/parser.c:43483
0xaea5a9 c_parse_file()
/src/gcc/61339/gcc/cp/parser.c:43491
0xcd3987 c_common_parse_file()
/src/gcc/61339/gcc/c-family/c-opts.c:1185
Please submit a full bug report,


Changing the assert to

  gcc_assert (!x.get (1));

leads to an infinite loop in hash_table::find_with_hash().

[Bug bootstrap/92762] hash_table::empty_slow invokes assignment on invalid objects

2019-12-02 Thread msebor at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92762

--- Comment #2 from Martin Sebor  ---
This bug is distinct from pr92761 because it's in hash_table::empty_slow() and
pr92761 is in hash_table::expand().  I expect to post a patch for both so I'm
fine with handling them together.

[Bug bootstrap/92762] hash_table::empty_slow invokes assignment on invalid objects

2019-12-02 Thread pinskia at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92762

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Andrew Pinski  ---
Again you did not provide the hash_trait.
PR 92761.

*** This bug has been marked as a duplicate of bug 92761 ***