public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "netletter at comder dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/16211] New: If mixing templates and va_list (va_arg) and char* string you wont be happy Date: Fri, 25 Jun 2004 22:22:00 -0000 [thread overview] Message-ID: <20040625222005.16211.netletter@comder.com> (raw) 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
next reply other threads:[~2004-06-25 22:20 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2004-06-25 22:22 netletter at comder dot com [this message] 2004-06-25 23:03 ` [Bug c++/16211] " pinskia at gcc dot gnu dot org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20040625222005.16211.netletter@comder.com \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).