public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/16211] New: If mixing templates and va_list (va_arg) and char* string you wont be happy
@ 2004-06-25 22:22 netletter at comder dot com
  2004-06-25 23:03 ` [Bug c++/16211] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: netletter at comder dot com @ 2004-06-25 22:22 UTC (permalink / raw)
  To: gcc-bugs

I hope I do not offend anyone, but this code seems to segfault. Im not even sure
what this form wants as host triplet. I read the guidlines, and got the picture
that you do not want source, but I cant explain this any other way. Well here
goes, hope Ill not make a total fool of myself.

The crash comes from an invalid address returned by va_arg( ). Undefine CRASH to
see it work as expected.

gcc version 3.3 20030226 (prerelease) (SuSE Linux)

------------ Code snipet ---------------
#include <stdarg.h> //	va_list
#include <stdio.h>

#define CRASH

void func( const char *str,... );

#ifdef CRASH
template< class TYPE > bool FormTest( const char* str,char* i )
{
	func( str,i );
	return true;
}
#else
bool FormTest( const char* str,char* i )
{
	func( str,i );
	return true;
}
#endif

int main( void )
{
#ifdef CRASH
	FormTest< char* >( "%s\n","string" );
#else
	FormTest( "%s\n","string" );
#endif
}

void func( const char *str,va_list &ap );

void func( const char *str,... )
{
	va_list ap; va_start( ap,str );
	func( str,ap );
	va_end( ap );
}

void func( const char *str,va_list &ap )
{
	const char *pek; int i;
	pek=va_arg( ap,const char* ); printf( str,pek );
}

-- 
           Summary: If mixing templates and va_list (va_arg) and char*
                    string you wont be happy
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: netletter at comder dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: /lib/ld-linux.so.2


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c++/16211] If mixing templates and va_list (va_arg) and char* string you wont be happy
  2004-06-25 22:22 [Bug c++/16211] New: If mixing templates and va_list (va_arg) and char* string you wont be happy netletter at comder dot com
@ 2004-06-25 23:03 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-06-25 23:03 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-06-25 23:02 -------
Fixed already in 3.3.3 so closing.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
           Keywords|                            |wrong-code
      Known to fail|                            |3.2.3
      Known to work|                            |3.3.3 3.4.0 3.5.0
         Resolution|                            |FIXED
   Target Milestone|---                         |3.3.3


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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-06-25 23:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-25 22:22 [Bug c++/16211] New: If mixing templates and va_list (va_arg) and char* string you wont be happy netletter at comder dot com
2004-06-25 23:03 ` [Bug c++/16211] " pinskia at gcc dot gnu dot org

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).