diff mbox

[trivial] Fix a potential bug of cost_classes_eq in ira-costs.c

Message ID DA41BE1DDCA941489001C7FBD7A8820E54A33480@szxema507-mbx.china.huawei.com
State New
Headers show

Commit Message

Yangfei (Felix) Dec. 30, 2013, 2:36 a.m. UTC
Ping.

Attached please find patch is for trunk (gcc-4.9):

Cheers,
Fei.


> Hi Vladimir,

> 

>   I am trying to fix a potential bug of cost_classes_eq in ira-costs.c. This patch

> is for gcc-4.8 branch and should work for gcc-4.9.

>   Library function memcmp return 0 if no difference for the two compared data.

> Please take a look.

> 

> 

> /* Compares cost classes info V1 and V2.  */ static int cost_classes_eq (const

> void *v1, const void *v2) {

>   const_cost_classes_t hv1 = (const_cost_classes_t) v1;

>   const_cost_classes_t hv2 = (const_cost_classes_t) v2;

> 

>   return hv1->num == hv2->num && memcmp (hv1->classes, hv2->classes,

> -					 sizeof (enum reg_class) * hv1->num);

> +					 sizeof (enum reg_class) * hv1->num) == 0;

> }

> 

> Cheers,

> Fei
diff mbox

Patch

Index: gcc/ira-costs.c
===================================================================
--- gcc/ira-costs.c	(revision 206236)
+++ gcc/ira-costs.c	(working copy)
@@ -155,7 +155,7 @@  inline bool
 cost_classes_hasher::equal (const value_type *hv1, const compare_type *hv2)  {
   return hv1->num == hv2->num && memcmp (hv1->classes, hv2->classes,
-					 sizeof (enum reg_class) * hv1->num);
+					 sizeof (enum reg_class) * hv1->num) == 0;
 }
 
 /* Delete cost classes info V from the hash table.  */