Gale Paeper wrote: <snip>
Although the complier doesn't have to statisfy any guarentees about economies of storage or efficiency of accesses, the compiler does have to handle assignment statements involving packed data structures as legal assignments.
I take it then that the problem has at least been put on the bug list to be investigated and fixed as time and circumstances permit addressing the problem?
While I do not know when Frank put bugs on the official bug list, problems signalled on the mailing list do get attention.
The following patch should fix problems with packed records:
diff -rbu gpc-20030830.orig/p/expressions.c gpc-20030830/p/expressions.c --- gpc-20030830.orig/p/expressions.c Wed Aug 13 06:29:55 2003 +++ gpc-20030830/p/expressions.c Tue Feb 10 02:50:52 2004 @@ -2754,7 +2754,7 @@ int noconvert; { /* No default_conversion here. It causes trouble for ADDR_EXPR. */ - tree arg = xarg, addr, argtype = 0, t; + tree arg = xarg, addr, argtype = 0; enum tree_code typecode = TREE_CODE (TREE_TYPE (arg)); const char *errstring = NULL;
@@ -2851,13 +2851,14 @@ if (TREE_CODE (arg) == ARRAY_REF) { tree index, array = TREE_OPERAND (arg, 0); - +#if 0 tree t = array; if (noconvert) /* Don't let mark_addressable do this, it would complain about packed fields */ while (TREE_CODE (t) == COMPONENT_REF) t = TREE_OPERAND (t, 0); - if (!mark_addressable (t)) +#endif + if (!mark_addressable2 (array, noconvert)) return error_mark_node;
if (!noconvert && PASCAL_TYPE_PACKED (TREE_TYPE (TREE_OPERAND (arg, 0)))) @@ -2925,13 +2926,14 @@ argtype = c_build_type_variant (argtype, TREE_READONLY (arg), TREE_THIS_VOLATILE (arg));
argtype = build_pointer_type (argtype); - +#if 0 t = arg; if (noconvert) /* Don't let mark_addressable do this, it would complain about packed fields */ while (TREE_CODE (t) == COMPONENT_REF) t = TREE_OPERAND (t, 0); - if (!mark_addressable (t)) +#endif + if (!mark_addressable2 (arg, noconvert)) return error_mark_node;
if (TREE_CODE (arg) == BIT_FIELD_REF && PASCAL_TYPE_PACKED (TREE_TYPE (TREE_OPERAND (arg, 0)))) diff -rbu gpc-20030830.orig/p/gpc.h gpc-20030830/p/gpc.h --- gpc-20030830.orig/p/gpc.h Sun Sep 14 01:16:10 2003 +++ gpc-20030830/p/gpc.h Tue Feb 10 01:59:29 2004 @@ -1189,6 +1189,9 @@ extern int lvalue_p PARAMS ((tree)); #ifdef GCC_3_3 extern bool mark_addressable PARAMS ((tree)); +extern bool mark_addressable2 PARAMS ((tree, int)); +#else +extern int mark_addressable2 PARAMS ((tree, int)); #endif #ifndef EGCS extern int mark_addressable PARAMS ((tree)); diff -rbu gpc-20030830.orig/p/typecheck.c gpc-20030830/p/typecheck.c --- gpc-20030830.orig/p/typecheck.c Wed Aug 13 06:27:31 2003 +++ gpc-20030830/p/typecheck.c Tue Feb 10 01:59:38 2004 @@ -2167,12 +2167,24 @@ mark_addressable (exp) tree exp; { + return mark_addressable2 (exp, 0); +} + +#ifdef GCC_3_3 +bool +#else +int +#endif +mark_addressable2 (exp, allow_packed) + tree exp; + int allow_packed; +{ tree x = exp; while (1) switch (TREE_CODE (x)) { case COMPONENT_REF: - if (DECL_PACKED_FIELD (TREE_OPERAND (x, 1))) + if ((DECL_PACKED_FIELD (TREE_OPERAND (x, 1))) && !allow_packed) { error ("cannot take address of packed record field `%s'", IDENTIFIER_NAME (DECL_NAME (TREE_OPERAND (x, 1)))); diff -rbu gpc-20030830.orig/p/types.c gpc-20030830/p/types.c --- gpc-20030830.orig/p/types.c Wed Aug 13 06:32:06 2003 +++ gpc-20030830/p/types.c Tue Feb 10 01:59:52 2004 @@ -2283,7 +2288,7 @@ /* Don't let mark_addressable do this, it would complain about packed fields */ while (TREE_CODE (t) == COMPONENT_REF) t = TREE_OPERAND (t, 0); - if (!mark_addressable (t)) + if (!mark_addressable2 (t, 1)) return error_mark_node; }