[Bug c++/10940] New: Explicit Template Specialization of Static Member Function Generates Bad Code

lakers@peachtree.com gcc-bugzilla@gcc.gnu.org
Thu May 22 17:10:00 GMT 2003


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10940

           Summary: Explicit Template Specialization of Static Member
                    Function Generates Bad Code
           Product: gcc
           Version: 3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: lakers@peachtree.com
                CC: gcc-bugs@gcc.gnu.org
 GCC build triplet: i686-pc-linux
  GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin

The program below will crash when run with a segmentation fault.  Compiling 
with the command line g++ -O3 -Wall main.cc produced the following incorrect 
warning which might help locate the problem.

main.cc:5 warning: 'int v' might be uninitialized in this function

---------------------------------------------------------------
template<int b>
class o
{
public:
	template<typename T> static void do_add(T* p, T v);
};

template<>
template<typename T>
inline void o<32>::do_add(T* p, T v)
{
	*p += v;
}

template<typename T> 
inline void add(T* p, T v)
{

	o<32>::do_add<T>(p, v);
}

int main()
{
	int a = 0x1000;
	add(&a, 0x2000);
	return a;
}
---------------------------------------------------------------

Environment:
cygwin on Windows XP

Release:
gcc version 3.2 20020927 (prerelease)



------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.



More information about the Gcc-bugs mailing list