From mboxrd@z Thu Jan 1 00:00:00 1970 From: SchirmerH@innovative-systems.de To: gcc-gnats@gcc.gnu.org Subject: c/4152: Incorrect code for va_arg(x,char) and va_arg(x,short) on SH Date: Mon, 27 Aug 2001 23:46:00 -0000 Message-id: <20010828064325.15223.qmail@sourceware.cygnus.com> X-SW-Source: 2001-08/msg00693.html List-Id: >Number: 4152 >Category: c >Synopsis: Incorrect code for va_arg(x,char) and va_arg(x,short) on SH >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Mon Aug 27 23:46:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: SchirmerH@innovative-systems.de >Release: unknown-1.0 >Organization: >Environment: Reading specs from /gcc-3.0.1-sh/lib/gcc-lib/sh-hitachi-coff/3.0.1/specs Configured with: ../gcc-3.0.1/configure --verbose --target=sh-hitachi-coff --pre fix=/gcc-3.0.1-sh --enable-haifa Thread model: single gcc version 3.0.1 >Description: GCC 3.0.1 emmits a warning compiling the attached source. To justify this warning it also produces incorrect code _test_char_char: mov #0,r1 mov.b @r1,r1 exts.b r6,r6 cmp/eq r6,r1 rts movt r0 .align 1 .global _test_char_short _test_char_short: mov #0,r1 mov.w @r1,r1 exts.w r6,r6 cmp/eq r6,r1 rts movt r0 .ident "GCC: (GNU) 3.0.1" a null pointer access is created. >How-To-Repeat: >Fix: >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="chk_stdarg2.c" Content-Disposition: inline; filename="chk_stdarg2.c" #include int test_char_char(int a, int b, char ok, int what, ...) { char value; va_list m; va_start(m,what); value = va_arg(m, char); va_end(m); return value == ok; } int test_char_short(int a, int b, short ok, int what, ...) { short value; va_list m; va_start(m,what); value = va_arg(m, short); va_end(m); return value == ok; }