"format not a string literal"

Kaveh R. Ghazi ghazi@caip.rutgers.edu
Sun Oct 31 23:03:00 GMT 1999


 > From: Ulrich Drepper <drepper@cygnus.com>
 > Date: 12 Oct 1999 14:05:36 -0700
 >  
 > "Kaveh R. Ghazi" <ghazi@caip.rutgers.edu> writes:
 >  
 > >       Eh?  Did you actually try this?  I don't see a problem.
 >  
 > Because you haven't used the right sources, headers, or options.  The
 > gettext calls in GNU gettext code actually expands into an statement
 > expression.  Like this (I cleaned it up):
 >  
 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 > void
 > __assert_fail (const char *assertion, const char *file, unsigned int
 > line,
 >                const char *function)
 > {
 >   (void) fprintf (stderr ,
 >                   (__extension__
 >                    ({
 >                       char *__result;
 >                       if (__builtin_constant_p (("%s%s%s:%u:
 > 		      %s%sAssertion `%s' failed.\n")))
 >                         {
 >                           static char *__translation__;
 >                           static int __catalog_counter__;
 >                           if (! __translation__
 >                               || __catalog_counter__ !=
 > 			      _nl_msg_cat_cntr)
 >                             {
 >                               __translation__ = __dcgettext
 > 			      ((_libc_intl_domainname  ),
 >                                                              (("%s%s%s:%u: %s%sAssertion `%s' failed.\n")), ( 5));
 >                               __catalog_counter__ = _nl_msg_cat_cntr;
 >                             }
 >                           __result = __translation__;
 >                         }
 >                       else
 >                         __result = __dcgettext ((_libc_intl_domainname
 > 			),
 >                                                  (("%s%s%s:%u:
 > 						 %s%sAssertion `%s'
 > 						 failed.\n")),
 >                                                  (5));
 >                         __result;
 >                     })),
 >                   __assert_program_name ? __assert_program_name : "",
 >                   __assert_program_name ? ": " : "",
 >                   file, line,
 >                   function ? function : "", function ? ": " : "",
 >                   assertion);
 >   (void) _IO_fflush (stderr);
 >  
 >   abort ();
 > }
 > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 >  
 > And this does not work with the warning mechanism.


Ah okay, the problem here is that the function complaining is not a
call to gettext, but the containing call to fprintf.  At the point cc1
sees this code, cpp has already substituted the stmt-expr for the call
to gettext.  So doing something special for intl functions as you
suggested earlier is not going to solve it.

I don't see any way to get around this short of putting a new
attribute in or turning off the warning. :-(

		--Kaveh
--
Kaveh R. Ghazi			Engagement Manager / Project Services
ghazi@caip.rutgers.edu		Qwest Internet Solutions



More information about the Gcc-bugs mailing list