Project

General

Profile

Actions

Bug #1333

open

CIL misses fields in unions

Added by Vadim Mutilin almost 13 years ago. Updated over 9 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
CIL
Start date:
06/08/2011
Due date:
% Done:

0%

Estimated time:
Detected in build:
657406aad
Platform:
Published in build:

Description

From the structure

struct kernel_param {
 const char *name;
 const struct kernel_param_ops *ops;
 u16 perm;
 u16 flags;
 union {
  void *arg;
  const struct kparam_string *str;
  const struct kparam_array *arr;
 };
};

it generates

struct kernel_param {
   char const   *name ;
   struct kernel_param_ops  const  *ops ;
   u16 perm ;
   u16 flags ;
   union __anonunion____missing_field_name_120 __annonCompField19 ;
};

where fields in union are missed.

After that CPAcheker fails with exception

unknown initializer: CASTDesignatedInitializer in line 8550: .arr = & __param_arr_eisa (CPAchecker.run, SEVERE)

for the code

static struct kernel_param  const  __param_eisa  __attribute__((__used__, __unused__,
__section__("__param"), __aligned__(sizeof(void *))))  =    {__param_str_eisa, (struct kernel_param_ops  const  *)(& param_array_ops), (u16 )0,
    (u16 )0, {.arr = & __param_arr_eisa}};

Actions #1

Updated by Evgeny Novikov almost 10 years ago

Proper place for CIL related bugs is its bugzilla, since we will unlikely fix them by ourselves. So reopen this issue there and mark this here.

Actions #2

Updated by Vadim Mutilin over 9 years ago

  • Category set to CIL
Actions #3

Updated by Mikhail Mandrykin over 9 years ago

I can't to reproduce the bug both with CIL 1.3.7 and 1.7.3 (development version).

The following code:

struct kernel_param {
 const char *name;
 const int *ops;
 unsigned short perm;
 unsigned short flags;
 union {
  void *arg;
  const int *str;
  const int *arr;
 };
};

static struct kernel_param  const  __param_eisa  __attribute__((__used__, __unused__,
__section__("__param"), __aligned__(sizeof(void *))))  =  {"y", (int  *)0, (unsigned short)0,
    (unsigned short)0, {.arr = (void *)0}};

is correctly transformed to

union __anonunion____missing_field_name_1 {
   void *arg ;
   int const   *str ;
   int const   *arr ;
};
struct kernel_param {
   char const   *name ;
   int const   *ops ;
   unsigned short perm ;
   unsigned short flags ;
   union __anonunion____missing_field_name_1 __annonCompField1 ;
};

static struct kernel_param  const  __param_eisa
  __attribute__((__used__, __unused__, __section__("__param"), __aligned__(sizeof(void *)))) 
   =
  {"y", (int const   *)((int *)0),
   (unsigned short)0, (unsigned short)0, {.arr = (int const   *)((void *)0)}};
Actions

Also available in: Atom PDF