Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
46 Views

__attribute__((__packed__)) on struct causes compilation error

icpc --version
icpc (ICC) 13.0.1 20121010

with attribute packed turn on gets this error:

test.cpp(27): error: invalid type conversion: "char *" to "const char (&)[7]"
   set(ms.data);

without the attribute packed it compiles fine.

is this correct behavior?

#include <iostream>
#include <string.h>

char msg[90];

//struct __attribute__((__packed__)) MyStruct
struct MyStruct                            
{
 char data[7];
};

void set( const char (&str)[7] )
{
memcpy(msg,str,7);
}



int main()
{
 char str[7];
 str[0] = '1';
 str[1] = 0;

 MyStruct ms;

 set(ms.data);
 set(str);
 std::cout << msg << std::endl;
 return 0;
}

0 Kudos
1 Reply
Highlighted
Employee
46 Views

 

This looks like a bug. I have entered it into our internal bug tracking database as DPD200248124. Thanks for reporting it to us.

Judy

0 Kudos