c/4154: copy a structure argument with negative length (gcc3.0.1 mips3)
saito@densan.co.jp
saito@densan.co.jp
Tue Aug 28 01:06:00 GMT 2001
>Number: 4154
>Category: c
>Synopsis: copy a structure argument with negative length (gcc3.0.1 mips3)
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Aug 28 01:06:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Hideo Saito
>Release: gcc-3.0.1
>Organization:
>Environment:
NetBSD-1.4.3 mips3(R5200) ELF
>Description:
When gcc passes some values and a structure argumnt to a function,
a structure argumnt is copied with negative length by memcpy().
FIX2 code generates same code as gcc-2.95.2 generates.
>How-To-Repeat:
struct sss {
char buf[20];
};
xxx(int x, int y, struct sss s)
{
}
main()
{
struct sss s0;
xxx(0, 1, s0);
}
>Fix:
FIX1:
--- calls.c.org Thu Aug 23 13:19:43 2001
+++ calls.c Tue Aug 28 15:40:27 2001
@@ -4598,6 +4598,7 @@
/* If parm is passed both in stack and in register and offset is
greater than reg_parm_stack_space, split the offset. */
+#if 1
if (arg->reg && arg->pass_on_stack)
{
if (arg->offset.constant < reg_parm_stack_space && arg->offset.var)
@@ -4615,9 +4616,13 @@
reg_parm_stack_space,
ARGS_SIZE_RTX (arg->alignment_pad));
- size_rtx = GEN_INT (INTVAL(size_rtx) - reg_parm_stack_space);
+ arg->value = change_address (arg->value, arg->mode,
+ plus_constant (XEXP (arg->value, 0), (INTVAL(size_rtx1))));
+ arg->offset.constant += INTVAL(size_rtx1);
+ size_rtx = GEN_INT (INTVAL(size_rtx) - INTVAL(size_rtx1));
}
}
+#endif
emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
FIX2:
--- calls.c.org Tue Aug 28 16:51:03 2001
+++ calls.c Tue Aug 28 16:51:58 2001
@@ -4598,6 +4598,7 @@
/* If parm is passed both in stack and in register and offset is
greater than reg_parm_stack_space, split the offset. */
+#if 0
if (arg->reg && arg->pass_on_stack)
{
if (arg->offset.constant < reg_parm_stack_space && arg->offset.var)
@@ -4618,6 +4619,7 @@
size_rtx = GEN_INT (INTVAL(size_rtx) - reg_parm_stack_space);
}
}
+#endif
emit_push_insn (arg->value, arg->mode, TREE_TYPE (pval), size_rtx,
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-prs
mailing list