public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* RE: c++/9942: Function Overload Resolution calls wrong function o n variable length parameter lists
@ 2003-03-05 18:06 Steve Wadsworth
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Wadsworth @ 2003-03-05 18:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9942; it has been noted by GNATS.

From: Steve Wadsworth <Steve_Wadsworth@portasystems.co.uk>
To: "'bangerth@dealii.org'" <bangerth@dealii.org>, 
	"'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>, "'gcc-prs@gcc.gnu.org'"
	 <gcc-prs@gcc.gnu.org>, "'nobody@gcc.gnu.org'" <nobody@gcc.gnu.org>, 
	"'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: RE: c++/9942: Function Overload Resolution calls wrong function o
	n variable length parameter lists
Date: Wed, 5 Mar 2003 18:11:36 -0000 

 This message is in MIME format. Since your mail reader does not understand
 this format, some or all of this message may not be legible.
 
 ------_=_NextPart_000_01C2E342.A968F590
 Content-Type: text/plain;
 	charset="iso-8859-1"
 
 Hi Wolfgang,
 
 Right now I'm having great difficulty reproducing this problem.
 
 The files I posted on the problem report are flawed I notice, hence it
 appears to exhibit my problem, but it's actually legitimate as I've renamed
 one of the function instances with a different name.
 
 I've gone back to my original source code - which is a rather large project
 build, with the "ServiceAppLight" and "Logger" classes in a statically
 linked library, to see if this was actually causing the compiler to exhibit
 the problem and I've now discovered that my original bug report was wrong.
 
 I'm not sure if this is a bug - but I now realise what my original problem
 is, and it's not what I reported. It's still function overload resolution,
 and it still works OK on the gcc with the previous version of Red Hat Linux,
 and with Tru64.
 
 It's where the call to the logEvent function has a character pointer as it's
 argument - then it gets a segment violation.
 
 Attached is sample code to exhibit this. 
 
 Regards,
 Steve
 
 
 -----Original Message-----
 From: bangerth@dealii.org [mailto:bangerth@dealii.org]
 Sent: 04 March 2003 22:39
 To: Steve_Wadsworth@Portasystems.co.uk; gcc-bugs@gcc.gnu.org;
 gcc-prs@gcc.gnu.org; nobody@gcc.gnu.org
 Subject: Re: c++/9942: Function Overload Resolution calls wrong function
 on variable length parameter lists
 
 
 Synopsis: Function Overload Resolution calls wrong function on variable
 length parameter lists
 
 State-Changed-From-To: open->feedback
 State-Changed-By: bangerth
 State-Changed-When: Tue Mar  4 22:38:56 2003
 State-Changed-Why:
     This is one of the rare cases where it would be helpful
     if we would have the original code from which you
     got the preprocessed one. I gather that it is relatively
     small, but I can't recreate the va_start calls etc.
     Could you possibly send them to me?
     
     Thanks
       Wolfgang
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p
 r=9942
 
 
 
 **********************************************************************
 This email and any files transmitted with it are confidential and
 intended solely for the use of the individual or entity to whom they
 are addressed. If you have received this email in error please notify
 the system manager. postmaster@portasystems.co.uk
 
 This footnote also confirms that this email message has been swept by
 MIMEsweeper for the presence of computer viruses.
 
 www.mimesweeper.com
 **********************************************************************
 
 ------_=_NextPart_000_01C2E342.A968F590
 Content-Type: application/octet-stream;
 	name="TestEventLog.cpp"
 Content-Transfer-Encoding: quoted-printable
 Content-Disposition: attachment;
 	filename="TestEventLog.cpp"
 
 /***********************************************************************=
 **/
 /*                                                                      =
  */
 /*  COPYRIGHT (c), 2002, Porta Systems Ltd.                             =
  */
 /*  All rights reserved. Any unauthorised reproduction is strictly      =
  */
 /*  prohibited.                                                         =
  */
 /*                                                                      =
  */
 #include <stdarg.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <string>
 using namespace std;
 #include <stdio.h>
 
 class Logger
 {
 public:
     enum EventType
     {
         DebugEvent  =3D 0x01,
         StatusEvent =3D 0x02,
         InfoEvent   =3D 0x04,
         WarnEvent   =3D 0x08,
         ErrorEvent  =3D 0x10,
         SystemEvent =3D 0x20,
         FatalEvent  =3D 0x40
     };
 
     // logging
     static void logEvent(EventType eventType, const char* eventId, =
 const char* format, ...);
     static void logEvent(EventType eventType, const char* eventId, =
 const char* format, va_list& args);  // To allow indirect calling via =
 another function
 };
 
 
 void Logger::logEvent(EventType eventType, const char* eventId, const =
 char* format, ...)
 {
     // format event message
     char eventMsg[4196];
     va_list args;
     va_start(args, format);
 
     vsprintf(eventMsg, format, args);
     va_end(args);
 }
 
 void Logger::logEvent(EventType eventType, const char* eventId, const =
 char* format, va_list& args)
 {
     // format event message
     char eventMsg[4196];
     vsprintf(eventMsg, format, args);
 }
 
 
 
 class ServiceAppLight
 {
 public:
     // logging
     static void logEvent(Logger::EventType eventType, const char* =
 eventId, const char* format, ...);
 };
 
 
 
 void ServiceAppLight::logEvent(Logger::EventType eventType, const char* =
 eventId, const char* format, ...)
 {
     va_list args;
     va_start(args, format);
     Logger::logEvent(eventType, eventId, format, args);
     va_end(args);
 }
 
 class MsgMoverService : public ServiceAppLight
 {
 public:
     MsgMoverService();
 
     int runService(int argc, char** argv);
 };
 
 MsgMoverService::MsgMoverService(): ServiceAppLight()
 {
 }
 
 
 int MsgMoverService::runService(int argc, char** argv)
 {
     char *Temp ;
     Temp =3D "Test String" ;
     Logger::logEvent(Logger::DebugEvent, "TEST", "Test Call %s", Temp);
 }
 
 
 int main(int argc, char** argv)
 {
     MsgMoverService msgMoverService;
     msgMoverService.runService(argc, argv);
 }
 
 ------_=_NextPart_000_01C2E342.A968F590--


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

* RE: c++/9942: Function Overload Resolution calls wrong function o n variable length parameter lists
@ 2003-03-05 23:06 Wolfgang Bangerth
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bangerth @ 2003-03-05 23:06 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/9942; it has been noted by GNATS.

From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: Steve Wadsworth <Steve_Wadsworth@portasystems.co.uk>
Cc: "'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>,
   "'gcc-gnats@gcc.gnu.org'" <gcc-gnats@gcc.gnu.org>
Subject: RE: c++/9942: Function Overload Resolution calls wrong function o
 n variable length parameter lists
Date: Wed, 5 Mar 2003 17:03:00 -0600 (CST)

 > Attached is sample code to exhibit this. 
 
 OK, here's a reduced example:
 ------------------------
 #include <stdarg.h>
 
 void f(int, va_list&)  ;   // only declared
 void f(int, ...)     {};   // defined
 
 int main () {
   char *p;
   f(1, p);         // should probably call second f()
 }
 ------------------------
 
 This compiles and links fine with 2.95, but not with 3.2.1. Will have to 
 check on that other system what happens with 3.3 and mainline.
 
 W.
 
 Here's the result:
 tmp/g> ~/bin/gcc-3.2.1/bin/c++ x.cc
 /tmp/ccOD0xO1.o: In function `main':
 /tmp/ccOD0xO1.o(.text+0x25): undefined reference to `f(int, char*&)'
 collect2: ld returned 1 exit status
 
 -------------------------------------------------------------------------
 Wolfgang Bangerth             email:            bangerth@ticam.utexas.edu
                               www: http://www.ticam.utexas.edu/~bangerth/
 
 


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

end of thread, other threads:[~2003-03-05 23:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-05 18:06 c++/9942: Function Overload Resolution calls wrong function o n variable length parameter lists Steve Wadsworth
2003-03-05 23:06 Wolfgang Bangerth

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