[SVN r188] Build fails on src/p_setup.cpp

Bugs that have been investigated and resolved somehow.

Moderator: GZDoom Developers

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.
Post Reply
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

[SVN r188] Build fails on src/p_setup.cpp

Post by Jim »

Code: Select all

Compiling p_setup.cpp:                                                [ERROR]
g++ -pipe -Wall -Wno-unused -fno-strict-aliasing -MMD -DHAVE_FILELENGTH -D__forceinline=inline -Izlib -IFLAC -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR -Isrc/ -Isrc/g_doom/ -Isrc/g_heretic/ -Isrc/g_hexen/ -Isrc/g_raven/ -Isrc/g_shared/ -Isrc/g_strife/ -Isrc/oplsynth/ -Isrc/sound/ -Isrc/sdl/ -DUSEASM=1 -D_DEBUG -g3 -o debugobj/p_setup.o -c src/p_setup.cpp
================================================================================
In file included from src/p_setup.cpp:60:
src/p_setup.h: In member function `void MapData::Seek(int)':
src/p_setup.h:56: warning: comparison between signed and unsigned integer
   expressions
src/p_setup.h: In member function `void MapData::Read(int, void*)':
src/p_setup.h:64: warning: comparison between signed and unsigned integer
   expressions
src/p_setup.h: In member function `DWORD MapData::Size(int)':
src/p_setup.h:73: warning: comparison between signed and unsigned integer
   expressions
src/p_setup.cpp: In function `int GetMapIndex(const char*, int, const char*)':
src/p_setup.cpp:212: error: type `GetMapIndex(const char*, int, const
   char*)::<anonymous struct>' composed from a local class is not a valid
   template-argument
src/p_setup.cpp:212: error:   trying to instantiate `template<class T, unsigned
   int N> char (& _ArraySizeHelper(T (&)[N]))[N]'
src/p_setup.cpp:212: error: no matching function for call to `_ArraySizeHelper(
   GetMapIndex(const char*, int, const char*)::<anonymous struct>[13])'
src/p_setup.cpp: In function `void P_LoadSubsectors(MapData*)':
src/p_setup.cpp:961: warning: comparison between signed and unsigned integer
   expressions
src/p_setup.cpp:971: warning: comparison between signed and unsigned integer
   expressions
src/p_setup.cpp:975: warning: long unsigned int format, int arg (arg 3)
make: *** [debugobj/p_setup.o] Error 1
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

Post by Jim »

Not fixed in revision 189:

Code: Select all

Compiling p_setup.cpp:                                                [ERROR]
g++ -pipe -Wall -Wno-unused -fno-strict-aliasing -MMD -DHAVE_FILELENGTH -D__forceinline=inline -Izlib -IFLAC -I/usr/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNEED_STRUPR -Isrc/ -Isrc/g_doom/ -Isrc/g_heretic/ -Isrc/g_hexen/ -Isrc/g_raven/ -Isrc/g_shared/ -Isrc/g_strife/ -Isrc/oplsynth/ -Isrc/sound/ -Isrc/sdl/ -DUSEASM=1 -D_DEBUG -g3 -o debugobj/p_setup.o -c src/p_setup.cpp
================================================================================
src/p_setup.cpp: In function `int GetMapIndex(const char*, int, const char*)':
src/p_setup.cpp:212: error: type `GetMapIndex(const char*, int, const
   char*)::checkstruct' composed from a local class is not a valid
   template-argument
src/p_setup.cpp:212: error:   trying to instantiate `template<class T, unsigned
   int N> char (& _ArraySizeHelper(T (&)[N]))[N]'
src/p_setup.cpp:212: error: no matching function for call to `_ArraySizeHelper(
   GetMapIndex(const char*, int, const char*)::checkstruct[13])'
make: *** [debugobj/p_setup.o] Error 1
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

GCC is [censored word] if it can't compile this. :(

I'm sorry but you have to wait a little longer for an update. I'm extending the map loader so I can't commit another update until tomorrow. If you want to compile it right now just replace the countof() call with the actual size of the array or move the class definition out of the function.
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

Post by Jim »

Sorry, no it is not valid C++. The following code is not either:

Code: Select all

template <typename T> void foo() {}
int main () { 
  struct S {}; 
  foo<S> (); 
}
Here's what I get with GCC 3.3.3:

Code: Select all

g++ compiler-error.cpp
compiler-error.cpp: In function `int main()':
compiler-error.cpp:4: error: template-argument `main()::S' uses local type `
   main()::S'
compiler-error.cpp:4: error: no matching function for call to `foo()'
Here is what I get with the Comeau C/C++ 4.3.3 Compiler Front-End online

Code: Select all

Comeau C/C++ 4.3.3 (Aug  6 2003 15:13:37) for ONLINE_EVALUATION_BETA1
Copyright 1988-2003 Comeau Computing.  All rights reserved.
MODE:strict errors C++

"ComeauTest.c", line 4: error: a template argument may not reference a local type
    foo<S> (); 
    ^

1 error detected in the compilation of "ComeauTest.c".
Here's the best explanation I've found for why it's not allowed:
http://cpptips.hyperformix.com/cpptips/no_local_templ_arg wrote:Local classes have internal linkage, which means that only the local function may access the class. But the template function or template class that uses the local class may be instantiated at link time. But how is the linker to see the local class? It can't, and so local classes can't be used as template arguments of functions and classes.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

Sounds like a purely theoretical reason to me. Don't tell me this can't be properly defined so that it works.
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

Post by Jim »

Randy fixed this in r191, but neither r191 nor r192 build out of the box either because of the small error I reported in Bugs.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49234
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

VC doesn't catch these errors. It's annoying!
Post Reply

Return to “Closed Bugs [GZDoom]”