From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15244 invoked by alias); 11 Aug 2010 11:55:39 -0000 Received: (qmail 15183 invoked by uid 48); 11 Aug 2010 11:55:23 -0000 Date: Wed, 11 Aug 2010 11:55:00 -0000 Message-ID: <20100811115523.15182.qmail@sourceware.org> X-Bugzilla-Reason: CC References: Subject: [Bug c++/45249] Indirect variable parameters sometimes cause segmentation fault In-Reply-To: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "redi at gcc dot gnu dot org" 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: 2010-08/txt/msg00838.txt.bz2 ------- Comment #17 from redi at gcc dot gnu dot org 2010-08-11 11:55 ------- As already stated, what you are doing is not valid C or C++, the standards do not guarantee the behaviour you are expecting w.r.t stack layout, and an optimising C or C++ compiler follows the rules of the language standard. If you want to rely on your assumptions write assembler or do not enable optimisation. (In reply to comment #13) > Created an attachment (id=21453) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21453&action=view) [edit] > Source file (example 2) > // linux (cannot use stdarg because this function does not take variable parameters and > // so the compiler generates an error (shouldn't it be a warning?). Have you checked how va_start is defined? void va_start(va_list ap, parmN); ... The parameter parmN is the identifier of the rightmost parameter in the variable parameter list in the function definition (the one just before the , ...). You use *format_address as parmN, which is not an identifier. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45249