xs_arrays.c:247: warning: format not a string literal and no format arguments

Normally, gcc issues this warning if *printf functions are being called with a non-literal first argument, and the respective warnings are enabled. (See also -Wformat, -Wformat-nonliteral, -Wformat-security in the gcc man page)  For example

#include <stdio.h> int main() { char foo[100]; scanf("%s", foo); printf(foo); /* compiler cannot inspect contents of foo */ return 0; }
$ gcc -Wformat -Wformat-security nonlit.c nonlit.c: In function 'main': nonlit.c:5: warning: format not a string literal and no format argumen +ts

It seems those warnings were enabled by default in gcc 4.2.1 (with my newer version I explicitly have to request them).

That said, I'm not sure where there would be something printf-related in your code... What is line 247?   Even the preprocessor expansion1 of your snippet reveals no (s|f)printf whatsoever:

SV* vec_zeros(int m) { int i; AV *myav; SV **svs; (svs = ((void)(sizeof(SV *) > 1 && (m) > ((size_t)~0)/sizeof(SV *) + && (Perl_croak_nocontext(PL_memory_wrap),0)), (SV **)Perl_safesysmal +loc((size_t)((m)*sizeof(SV *))))); for (i = 0; i < m; i++) { svs[i] = Perl_sv_newmortal(((PerlInterpreter *)pthread_getspec +ific((*Perl_Gthr_key_ptr(((void *)0)))))); Perl_sv_setnv(((PerlInterpreter *)pthread_getspecific((*Perl_G +thr_key_ptr(((void *)0))))), (SV*)svs[i],0.0f); } myav = Perl_av_make(((PerlInterpreter *)pthread_getspecific((*Perl +_Gthr_key_ptr(((void *)0))))), m,svs); Perl_safesysfree((void *)(svs)); return Perl_newRV_noinc(((PerlInterpreter *)pthread_getspecific((* +Perl_Gthr_key_ptr(((void *)0))))), (SV*) myav); }

Anyhow, most likely, you can just ignore the warning, or disable it with -Wno-format.

___

1 done with gcc option -E, on a Linux system, with a perl built with "usemymalloc=n" (like yours).


In reply to Re: Newx compiler warnings by Eliya
in thread Newx compiler warnings by wbirkett

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.