* C++ va_list wromng code generation in class::method(...,va_list args) only
@ 2012-03-30 16:32 Bernd Roesch
2012-03-31 10:44 ` Mikael Pettersson
0 siblings, 1 reply; 2+ messages in thread
From: Bernd Roesch @ 2012-03-30 16:32 UTC (permalink / raw)
To: gcc
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: C++ va_list wromng code generation in class::method(...,va_list args) only
2012-03-30 16:32 C++ va_list wromng code generation in class::method(...,va_list args) only Bernd Roesch
@ 2012-03-31 10:44 ` Mikael Pettersson
0 siblings, 0 replies; 2+ messages in thread
From: Mikael Pettersson @ 2012-03-31 10:44 UTC (permalink / raw)
To: Bernd Roesch; +Cc: gcc
Bernd Roesch writes:
> 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
Please read <http://gcc.gnu.org/bugs/#report> and then enter a bug report in gcc's bugzilla.
The source attached here is too incomplete to be useful.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-31 10:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-30 16:32 C++ va_list wromng code generation in class::method(...,va_list args) only Bernd Roesch
2012-03-31 10:44 ` Mikael Pettersson
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).