This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

Re: Bug in _VFPRINTF_R


Eric Blake-1 wrote:
Slightly optimized patch checked in:

Index: libc/stdio/vfprintf.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/vfprintf.c,v
...
+#ifndef __OPTIMIZE_SIZE__
+                       /* Behavior is undefined if the user passed a
+                          NULL string when precision is not 0.
+                          However, if we are not optimizing for size,
+                          we might as well mirror glibc behavior.  */
+                       if (cp == NULL) {
                                cp = "(null)";
-                               size = 6;
+                               size = ((unsigned) prec > 6U) ? 6 : prec;
                        }
+#endif /* __OPTIMIZE_SIZE__ */
 #ifdef _MB_CAPABLE
                        else if (ch == 'S' || (flags & LONGINT)) {
...

Probaly this patch is a cause of the error when using with specific build params.
In case when the size optimization is turned on (like for me) then it leads to bad C syntax (an else clause without preceeding if) and thus compilation error:


arm-elf-gcc -B/home/artur/build/arm-elf/thumb/newlib/ -isystem /home/artur/build/arm-elf/thumb/newlib/targ-include -isystem /home/artur/newlib/newlib/libc/include -mthumb -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION=\"1.15.0\" -DPACKAGE_STRING=\"newlib\ 1.15.0\" -DPACKAGE_BUGREPORT=\"\" -I. -I../../../../../../newlib/newlib/libc/stdio -Os -D__NO_SYSCALLS__ -DNO_FLOATING_POINT -fno-builtin -DREENTRANT_SYSCALLS_PROVIDED -D__BUFSIZ__=64 -D__FILENAME_MAX__=32 -DNO_EXEC -DMALLOC_PROVIDED -g -Os -mthumb -fshort-enums -DINTEGER_ONLY -c ../../../../../../newlib/newlib/libc/stdio/vfprintf.c -o lib_a-vfiprintf.o
../../../../../../newlib/newlib/libc/stdio/vfprintf.c: In function ‘_vfiprintf_r’:
../../../../../../newlib/newlib/libc/stdio/vfprintf.c:1105: error: expected expression before ‘else’
make[8]: *** [lib_a-vfiprintf.o] Error 1



Currently I use the following patch/hack for clean build (it is against an hour old CVS snapshot):


--- newlib/libc/stdio/vfprintf.c.org    2007-10-13 17:01:21.000000000 +0200
+++ newlib/libc/stdio/vfprintf.c        2007-10-13 17:03:06.000000000 +0200
@@ -1039,6 +1039,10 @@
                                cp = "(null)";
                                size = ((unsigned) prec > 6U) ? 6 : prec;
                        }
+#else /* __OPTIMIZE_SIZE__ */
+            if (0) {
+                ;
+            }
 #endif /* __OPTIMIZE_SIZE__ */
 #ifdef _MB_CAPABLE
                        else if (ch == 'S' || (flags & LONGINT)) {



Regards,
--
Artur Lipowski


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