This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Believe found bug, would like to be sure w/experts POV


   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;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]