This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Believe found bug, would like to be sure w/experts POV
- From: George Garvey <tmwg-gcc at inxservices dot com>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 6 Sep 2004 20:44:11 -0700
- Subject: Believe found bug, would like to be sure w/experts POV
- Organization: inX Services, Los Angeles, CA, USA
I believe the following code represents a g++ bug. It is selecting a
method based on char * being the same as va_list.
The output is:
/tmp/bug
called ...
called va_list
It was just compiled as g++ -o bug bug.cc.
Perhaps this is not really a bug, and there is no distinction between
char * and va_list except in this head. Before reporting it, wanted to be
sure it isn't a misunderstanding of mine. I would have sworn that this used
to work as I expected, but maybe not.
The stripped down Linux code (I know all the headers aren't necessary,
but wanted to try to reproduce conditions as much as possible):
#include <inttypes.h>
#include <sys/types.h>
#include <sys/time.h>
#include <cstring>
#include <exception>
#include <string>
#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;
}