Jan Hauer wrote:

Hi everyone,

when a function returns a struct it works fine as long as the struct
does not contain bitfields with more than 16 bits in total. Otherwise
I get an internal compiler error:

app.c: In function `foo':
app.c:9: insn does not satisfy its constraints:
(insn 49 47 52 (set (reg/i:SI 15 r15)
       (reg:SI 13 r13 [37])) 57 {*movsi3} (insn_list 41 (nil))
   (nil))
app.c:9: Internal compiler error in reload_cse_simplify_operands, at 
reload1.c:8346
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Example program (app.c):

/****** START *******/
typedef struct {
unsigned int x: 8; unsigned int y: 9; } settings_t;

settings_t foo(){
 settings_t s = {1,2};
 return s;
}

int main(){
settings_t s = foo(); }
/****** STOP *******/

To me the code looks legal, so I guess it is a bug in the compiler,
comments ?

Regards,
Jan

From K&R 2nd, pp150
"Almost everything about fields is implemtation-dependent. Whether a field may overlap a word boundary is implemtation defined. Fields need not be named; unamed fields (a colon and width only) are used for padding. The special width 0 may be used to force alignment to the next word boundary."
So, you might try:

typedef struct {
unsigned int x: 8; unsigned int y: 9; unsigned int : 0; } settings_t;

Your example not only has more than 16 bits, it is not aligned to a word 
boundary, so the exact problem is not clear.

Garst



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users



Reply via email to