Opened 18 years ago

Closed 18 years ago

Last modified 11 years ago

#3030 closed defect (fixed)

PARA: parallaction code is not 64-bit safe

Reported by: SF/thomasklausner Owned by: peres
Priority: normal Component: Engine: Parallaction
Version: Keywords:
Cc: Game: Nippon Safes

Description

When compiling the SVN version from 20070129 with ----enable-parallaction on NetBSD-4.99.9/amd64, there are a number of warnings and (at least one) fatal error: engines/parallaction/commands.cpp: In function 'Parallaction::Command* Parallaction::parseCommands(Parallaction::ArchivedFile*)': engines/parallaction/commands.cpp:71: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:73: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:81: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:122: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:149: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:152: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:174: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/commands.cpp:177: warning: cast from type 'char**' to type 'const char**' casts away constness ... ./engines/parallaction/graphics.h:28: warning: #pragma pack(push[, id], <n>) is not supported on this target ./engines/parallaction/graphics.h:52: warning: #pragma pack(pop[, id], <n>) is not supported on this target engines/parallaction/dialogue.cpp: In function 'Parallaction::Dialogue* Parallaction::parseDialogue(Parallaction::ArchivedFile*)': engines/parallaction/dialogue.cpp:96: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/dialogue.cpp:103: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/dialogue.cpp:152: warning: cast from type 'char**' to type 'const char**' casts away constness engines/parallaction/dialogue.cpp: In function 'void Parallaction::runDialogue(Parallaction::SpeakData*)': engines/parallaction/dialogue.cpp:396: error: cast from 'byte*' to 'uint32' loses precision

Ticket imported from: #1648325. Ticket imported from: bugs/3030.

Change History (21)

comment:1 by fingolfin, 18 years ago

Uhm, this doesn't look like a 64 bit issue. Rather it looks as if you are using a bad compiler (which one, BTW? which version).

For example those const warnings are obviously total bogus -- we are *adding* a const qualifier, not casting it away.

And if "pragma pack" is not supported, several other engines (e.g. SCUMM) won't work correctly either.

comment:2 by fingolfin, 18 years ago

Owner: set to peres
Summary: parallaction code is not 64-bit safePARA: parallaction code is not 64-bit safe

comment:3 by fingolfin, 18 years ago

(but the actual error here, the cast from byte* to uint32, is very harmless and trivial to fix: peres, instead of using %x to print a pointer, use %p and cast the pointer to (const void*) )

comment:4 by SF/thomasklausner, 18 years ago

Sorry for not mentioning this earlier: The compiler is "gcc (GCC) 4.1.2 20070110 prerelease (NetBSD nb1 20070110)"

comment:5 by peres, 18 years ago

I fixed the only error in the list. Since the other warnings aren't to be considered - as Fingolfin pointed out - I would close this tracker item if there are no objections.

comment:6 by sev-, 18 years ago

Resolution: fixed
Status: newclosed

comment:7 by eriktorbjorn, 18 years ago

GCC from Debian unstable ("gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)") warns about casting from 'char**' to 'const char**' too. If the warning is bogus, I'm grateful because I never managed to make any sense out of it. :-)

comment:8 by fingolfin, 18 years ago

Yeah, the warning is nonsense.

However, maybe the compiler can be tricked into not warning by switching to a const_cast... If you can reproduce the warning, maybe try chanign one of the (const char **)foo casts to const_cast<const char **>(foo) -- does that help?

comment:9 by eriktorbjorn, 18 years ago

That trick did silence the warning. At least in the cases where I tried it.

comment:10 by fingolfin, 18 years ago

Feel free to add it in all places you get that const warning -- I can't do that as I don't get a warning.

That said, I still consider the warning presented here as totally bogus: The text is clearly wrong and misleading, and even if it was changed: Adding a const qualifier is always allowed. Seems to me a bug in that prerelease GCC which should be reported so that they can fix it.

comment:11 by eriktorbjorn, 18 years ago

Ok, I've done so, and not just in the Parallaction engine. The only other warnings I get now are from the MT-32 emulator, and I try to steer clear of that one.

comment:12 by SF/thomasklausner, 18 years ago

Thanks for fixing the first error in dialogue.cpp and the warnings!

However, there are more errors in graphics.cpp: engines/parallaction/graphics.cpp: In member function 'void Parallaction::Graphics::flatBlit(uint16, uint16, int16, int16, byte*, Parallaction::Graphics::Buffers)': engines/parallaction/graphics.cpp:387: error: cast from 'byte*' to 'uint32' loses precision engines/parallaction/graphics.cpp:387: error: cast from 'byte*' to 'uint32' loses precision

comment:13 by SF/thomasklausner, 18 years ago

Resolution: fixed
Status: closednew

comment:14 by peres, 18 years ago

Ok. Your casting problems should be solved now. I promise I will be more careful in the future. :)

comment:15 by peres, 18 years ago

Status: newclosed

comment:16 by sev-, 18 years ago

Resolution: fixed

comment:17 by SF/thomasklausner, 18 years ago

One last one: engines/parallaction/music.cpp: In function 'void Parallaction::playMusic()': engines/parallaction/music.cpp:75: error: cast from 'byte*' to 'uint32' loses precision

I tried 'gmake -k' this time, so I think this should really be the last one. I probably should have done that sooner, sorry.

Thanks for your fixes!

comment:18 by SF/thomasklausner, 18 years ago

Resolution: fixed
Status: closednew

comment:19 by peres, 18 years ago

Status: newclosed

comment:20 by sev-, 18 years ago

Resolution: fixed

comment:21 by Strangerke, 11 years ago

Component: --Unset--Engine: Parallaction
Game: Nippon Safes
Note: See TracTickets for help on using tickets.