From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23821 invoked by alias); 2 Oct 2011 19:48:20 -0000 Received: (qmail 23808 invoked by uid 22791); 2 Oct 2011 19:48:19 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,TW_SV,TW_VF X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 02 Oct 2011 19:48:06 +0000 From: "svfuerst at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/50581] stdarg doesn't support array types Date: Sun, 02 Oct 2011 19:48:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: svfuerst at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-10/txt/msg00065.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50581 Steven Fuerst changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |svfuerst at gmail dot com --- Comment #7 from Steven Fuerst 2011-10-02 19:47:46 UTC --- > Actually, I'm not sure why va_list is defined as an array in some of the architectures. The underlying issue is that the ABI on some architectures requires it. They may use "register windows" instead of stacks to pass parameters to functions. i.e. r1-r5 might refer to the registers in the function that called you. r6-r10 might refer to the registers in the function that called the function that called you. etc. The act of calling a function then changes the values a set of registers refers to. So when you call a function, what it sees as r6-r10 are the values that you see in r1-r5. With this type of ABI, you access your parameters from i.e. r1-r5. Any functions that you call cannot do this though... as the registers are renamed. So va_list cannot be a pointer type as there is nothing to point to. So how do you implement va_args for these arches then? The trick is to use an array. C requires that an array decays to a pointer when it is passed as an argument. This means that the array must be stored on the stack, and not in the renamable registers. This allows the code to get a handle on how many stack (and register) frames up the calling sequence it needs to go to find the parameters. The array can then store information about i.e. how many integer and floating point registers have been read from the variable argument list.