Modify

Ticket #8568 (closed Bugs: fixed)

Opened 11 months ago

Last modified 6 months ago

Infinite loop in hash_value_signed/hash_value_unsigned

Reported by: alex@… Owned by: danieljames
Milestone: To Be Determined Component: hash
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

Visual C++ 2012 static analysis found these two infinite loop warnings in hash.hpp:

for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits)
{
    seed ^= (std::size_t) (positive >> i) + (seed<<6) + (seed>>2);
}

Warning message:

hash.hpp(156): warning : C6295: Ill-defined for-loop:  'unsigned int' values are always of range '0' to '4294967295'.  Loop executes infinitely.
hash.hpp(176): warning : C6295: Ill-defined for-loop:  'unsigned int' values are always of range '0' to '4294967295'.  Loop executes infinitely.

Attachments

loop_warning.patch Download (1.7 KB) - added by Bikineev Anton <abikineev@…> 10 months ago.
pragma warning disable for msvc is added

Change History

Changed 10 months ago by Bikineev Anton <abikineev@…>

pragma warning disable for msvc is added

comment:1 Changed 9 months ago by anonymous

  • Owner changed from no-maintainer to danieljames
  • Component changed from functional to hash

comment:2 Changed 8 months ago by danieljames

(In [85248]) Fix Visual C++ warning in hash. Refs #8568.

I changed this a little from the patch on #8568. I moved the pragmas to the start and end of the file because I don't like to little the body of the code with them (this does mean I've disabled a potentially useful warning, but the code is pretty stable nowadays).

I also removed the version checks, as the warning should be present in later versions.

comment:3 Changed 8 months ago by danieljames

  • Status changed from new to closed
  • Resolution set to fixed

(In [85389]) Merge Hash. Fixes #8568, Refs #8822.#8822.#8822.

comment:4 Changed 6 months ago by qiaozhiqiang@…

unsigned int i, so i >= 0, so i > 0 is i != 0

we should change i > 0 to i != 0 to avoid warning.

View

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
The resolution will be deleted. Next status will be 'reopened'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.