From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7970 invoked by alias); 30 Mar 2012 16:32:26 -0000 Received: (qmail 7956 invoked by uid 22791); 30 Mar 2012 16:32:23 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_HOSTKARMA_NO,RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mailout-de.gmx.net) (213.165.64.23) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Fri, 30 Mar 2012 16:32:10 +0000 Received: (qmail invoked by alias); 30 Mar 2012 16:32:08 -0000 Received: from p5DDDEF24.dip.t-dialin.net (EHLO gmx.de) [93.221.239.36] by mail.gmx.net (mp069) with SMTP; 30 Mar 2012 18:32:08 +0200 From: Bernd Roesch To: gcc@gcc.gnu.org Date: Fri, 30 Mar 2012 16:32:00 -0000 Message-ID: Subject: C++ va_list wromng code generation in class::method(...,va_list args) only MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2012-03/txt/msg00547.txt.bz2 hello there is a C++ game called dunelegacy which work on other GCC architecture ok On G++ 68k it compile ok, but produce wrong code, because there seem something diffrent in va_list. The value of SDL_RWops is transfer wrong. I do not understand what backend problem is possible to cause this. Please help.va_list use the builtin GCC functions this happen on all 68k compilers i test. (3.x and some 4.x) See also the source attached of this class the program flow of the critical part begin here. Wsafile::Wsafile(SDL_RWops* RWop) { readdata(1,RWop); } ...... now there are 2 Methods named readdata, and gcc call the 2. one. This work wrong. Only when called the first is ok. ..... void Wsafile::readdata(int NumFiles, ...) { va_list args; va_start(args,NumFiles); readdata(NumFiles,args); va_end(args); } /// Helper method for reading and concatinating various WSA-Files. /** This methods reads from the RWops all data and concatinates all the frames to one animation. The SDL_RWops can be readonly but must support seeking. \param NumFiles Number of SDL_RWops \param args SDL_RWops for each wsa-File should be in this va_list. (can be readonly) */ void Wsafile::readdata(int NumFiles, va_list args) { unsigned char** Filedata; Uint32** Index; Uint16* NumberOfFrames; bool* extended; if((Filedata = (unsigned char**) malloc(sizeof(unsigned char*) * NumFiles)) == NULL) { fprintf(stderr, "Wsafile::readdata(): Unable to allocate memory!\n"); exit(EXIT_FAILURE); } ..................... when i change code to this and rename the first readdata method to readdata_first then it work Wsafile::Wsafile(SDL_RWops* RWop) { readdata_first(1,RWop); <---- I change that line } now there is called this method before and all work ok void Wsafile::readdata_frist(int NumFiles, ...) { <---- I rename readdata to readdata_first. va_list args; va_start(args,NumFiles); readdata(NumFiles,args); va_end(args); } /// Helper method for reading and concatinating various WSA-Files. /** This methods reads from the RWops all data and concatinates all the frames to one animation. The SDL_RWops can be readonly but must support seeking. \param NumFiles Number of SDL_RWops \param args SDL_RWops for each wsa-File should be in this va_list. (can be readonly) */ void Wsafile::readdata(int NumFiles, va_list args) { unsigned char** Filedata; Uint32** Index; Uint16* NumberOfFrames; bool* extended; if((Filedata = (unsigned char**) malloc(sizeof(unsigned char*) * NumFiles)) == NULL) { fprintf(stderr, "Wsafile::readdata(): Unable to allocate memory!\n"); exit(EXIT_FAILURE); } .......... int WsaFilesize; RWop = va_arg(args,SDL_RWops*); Filedata[i] = readfile(RWop,&WsaFilesize); <--- here crash, when not the 1. method is called before Bye