public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Bernd Roesch <nospamname@gmx.de>
To: gcc@gcc.gnu.org
Subject: C++ va_list wromng code generation in class::method(...,va_list args) only
Date: Fri, 30 Mar 2012 16:32:00 -0000	[thread overview]
Message-ID: <yam12507.2193.287095744@mail.gmx.net> (raw)

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

             reply	other threads:[~2012-03-30 16:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-30 16:32 Bernd Roesch [this message]
2012-03-31 10:44 ` Mikael Pettersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=yam12507.2193.287095744@mail.gmx.net \
    --to=nospamname@gmx.de \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).