This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Problem with vprintf () in Clang 3.4.2
- From: Thomas Wuillemin <thomas dot wuillemin at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Tue, 3 Feb 2015 16:50:30 -0300
- Subject: Problem with vprintf () in Clang 3.4.2
- Authentication-results: sourceware.org; auth=none
- Reply-to: thomas dot wuillemin at gmail dot com
Dear all,
While running some simple tests with the C vprintf function, I
detected different results between Gcc and Clang , where Clang seems
to be badly wrong.
Here is the faulty code that leads to a reproducible error (at least
in my configuration):
----------------------------------------------------
#include <stdio.h>
#include <stdarg.h>
void my_print1(char *format, ...)
{
va_list arguments;
va_start ( arguments, format );
vprintf ( format, arguments );
va_end ( arguments );
}
void my_print2(char *format, ...)
{
va_list arguments;
int value;
va_start ( arguments, format );
value = va_arg ( arguments, int );
printf ( format, value );
va_end ( arguments );
}
int main (int argc, char* argv[])
{
(void) argc;
(void) argv;
my_print1 ( "Variadic argument found (should be 1): %d\n", 1 );
my_print2 ( "Variadic argument found (should be 1): %d\n", 1 );
return 0;
}
----------------------------------------------------
Compiled with gcc, the results are good:
$ gcc -Wall -Wextra -pedantic -g -O0 dummy.c -o dummy.exe
$ ./dummy.exe
Variadic argument found (should be 1): 1
Variadic argument found (should be 1): 1
Compiled with Clang, the results show a little issue:
$ clang -Wall -Wextra -pedantic -g -O0 dummy.c -o dummy.exe
$ ./dummy.exe
Variadic argument found (should be 1): 2271896
Variadic argument found (should be 1): 1
Working with char*, leads equally to various corruptions.
Is anyone already experienced such issue (or could confirm it) ?
Best regards,
Thomas
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple