Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 63116

Summary: g++ 3.3.4-r1 picks wrong method, confusing char* and va_list
Product: Gentoo Linux Reporter: George Garvey <tmwg>
Component: [OLD] DevelopmentAssignee: Gentoo Linux bug wranglers <bug-wranglers>
Status: RESOLVED DUPLICATE    
Severity: critical    
Priority: High    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description George Garvey 2004-09-07 05:25:35 UTC
g++ incorrectly picks method for va_list when given a char * parameter. Small file that shows the problem will be attached. When run, it shows that two methods from a class are selected, when only one should be considered.

Have not verified if this is in the base gcc package.

Reproducible: Always
Steps to Reproduce:
1. g++ -o bug bug.cc
2. ./bug
3.

Actual Results:  
Wrong output to stdio.

Expected Results:  
Used the same class method for both calls.

/*
#include <inttypes.h>
#include <sys/types.h>
#include <sys/time.h>
#include <cstring>
#include <exception>
#include <string>
*/
#include <cstdarg>
#include <iostream>
#define  TIME_VAL          timeval

   class Bug {
      public:
            static void Log(const bool to_stderr, const char *format, ...)
               __attribute__ ((format (printf, 2, 3)));
            static void Log(const bool to_stderr, const TIME_VAL &when,
                              const char *format, ...
                           )
               __attribute__ ((format (printf, 3, 4)));

            static void Log(const bool to_stderr, const char *format,
                              va_list arg
                           );
            static void Log(const bool to_stderr, const TIME_VAL &when,
                              const char *format, va_list arg
                           );
   };

   using namespace std;

void
Bug::Log(const bool to_stderr, const char *format, ...) {
   cerr << "called ..." << endl;
}

void
Bug::Log(const bool to_stderr, const char *format, va_list arg) {
   cerr << "called va_list" << endl;
}

int
main(const int, char *const *) {
   char buffer[32];

   Bug::Log(false, "stuff %d\n", 1);
   Bug::Log(false, "stuff %s\n", buffer);
   return 0;
}
Comment 1 Rainer Größlinger (RETIRED) gentoo-dev 2004-09-07 05:28:58 UTC

*** This bug has been marked as a duplicate of 63112 ***