Project

General

Profile

Actions

Bug #7673

closed

Wrong transformation with type conversion

Added by Anton Vasilyev over 7 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Category:
C back-end
Start date:
11/02/2016
Due date:
% Done:

0%

Estimated time:
Detected in build:
svn
Platform:
Linux x64
Published in build:

Description

CIF transforms

u8 *dst; *(u16 *)(dst + 4) 
to
*((u16 *)dst + 4U) 
with different meaning: first has offset 32 from dst, second has offset 64 from dst.
Source code is attached.

It seem that the same problem occurs with:

#define container_of(ptr, type, member) ({                      \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
#define to_usb_device(d) container_of(d, struct usb_device, dev)
static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
{
  return to_usb_device(intf->dev.parent);
}

CIF omits conversion (char *)__mptr

__inline static struct usb_device *interface_to_usbdev(struct usb_interface *intf ) 
{ 
  struct device  const  *__mptr ;

  {
    __mptr = (struct device  const  *)intf->dev.parent;
    return ((struct usb_device *)__mptr + 0xffffffffffffff70UL);
  }
}


Files

ether_addr_copy (225 Bytes) ether_addr_copy Anton Vasilyev, 11/02/2016 04:58 PM

Related issues 1 (0 open1 closed)

Related to C Instrumentation Framework - Bug #7833: Wrong array address transformationRejected01/09/2017

Actions
Actions #1

Updated by Evgeny Novikov over 7 years ago

I fixed the first part of the given issue in 841586c several months ago. The second part looks to be unrelated and more complicated.

Actions #2

Updated by Anton Vasilyev about 7 years ago

#define container_of(ptr, type, member) ({                      \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
#define to_usb_device(d) container_of(d, struct usb_device, dev)
static inline struct usb_device *interface_to_usbdev(struct usb_interface *intf)
{
  return to_usb_device(intf->dev.parent);
}

Should be:

__inline static struct usb_device *interface_to_usbdev(struct usb_interface *intf ) 
{ 
  struct device  const  *__mptr ;

  {
    __mptr = (struct device  const  *)intf->dev.parent;
    return ((struct usb_device *)( (char *)__mptr + 0xffffffffffffff70UL) );
  }
}

but CIF produce:

__inline static struct usb_device *interface_to_usbdev(struct usb_interface *intf ) 
{ 
  struct device  const  *__mptr ;

  {
    __mptr = (struct device  const  *)intf->dev.parent;
    return ((struct usb_device *)__mptr + 0xffffffffffffff70UL);
  }
}

Actions #3

Updated by Evgeny Novikov about 7 years ago

  • Status changed from New to Closed

I fixed this issue at last in 54e8a248.

Actions #4

Updated by Evgeny Novikov almost 4 years ago

I fixed this issue one more time in e5f3be7 since my previous fix was broken when merging with the GCC master branch.

Actions

Also available in: Atom PDF