public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -Wno-format-contains-nul
@ 2018-06-20 18:26 Bruce Korb
  2018-06-20 18:40 ` -Wno-format-contains-nul Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Bruce Korb @ 2018-06-20 18:26 UTC (permalink / raw)
  To: GCC List

Years and years ago, I went to a mess of trouble to implement this
specialized warning so I would not have to see it anymore. I use a code
generator that puts constant strings into one huge buffer with all the
contained strings NUL separated.  Today, I was trying to build on OS/X:

libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../lib -g -O2
-Wcast-align -Wmissing-prototypes -Wpointer-arith -Wshadow
-Wstrict-prototypes -Wwrite-strings -Wno-format-contains-nul
-fno-strict-aliasing -Wstrict-aliasing=2 -MT libopts_la-libopts.lo -MD -MP
-MF .deps/libopts_la-libopts.Tpo -c libopts.c  -fno-common -DPIC -o
.libs/libopts_la-libopts.o

warning: unknown warning option '-Wno-format-contains-nul'
[-Wunknown-warning-option]
In file included from libopts.c:26:
./enum.c:112:38: warning: format string contains '\0' within the string
body [-Wformat]
            fprintf(option_usage_fp, ENUM_ERR_LINE, *(paz_names++));
                                     ^~~~~~~~~~~~~
./ao-strs.h:70:31: note: expanded from macro 'ENUM_ERR_LINE'
#define ENUM_ERR_LINE         (ao_strs_strtable+304)
                              ^~~~~~~~~~~~~~~~~~~~~~
./ao-strs.c:90:20: note: format string is defined here
/*   304 */ "  %s\n\0"
~~~~~~~~~~~~~~~~~~~^~~


Did somebody go to a bunch of trouble to undo my work for the OS/X
platform? :(
-- 
 - Bruce

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: -Wno-format-contains-nul
  2018-06-20 18:26 -Wno-format-contains-nul Bruce Korb
@ 2018-06-20 18:40 ` Jakub Jelinek
  2018-06-20 18:48   ` -Wno-format-contains-nul Bruce Korb
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2018-06-20 18:40 UTC (permalink / raw)
  To: Bruce Korb; +Cc: GCC List

On Wed, Jun 20, 2018 at 11:17:50AM -0700, Bruce Korb wrote:
> Years and years ago, I went to a mess of trouble to implement this
> specialized warning so I would not have to see it anymore. I use a code
> generator that puts constant strings into one huge buffer with all the
> contained strings NUL separated.  Today, I was trying to build on OS/X:
> 
> libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../lib -g -O2
> -Wcast-align -Wmissing-prototypes -Wpointer-arith -Wshadow
> -Wstrict-prototypes -Wwrite-strings -Wno-format-contains-nul
> -fno-strict-aliasing -Wstrict-aliasing=2 -MT libopts_la-libopts.lo -MD -MP
> -MF .deps/libopts_la-libopts.Tpo -c libopts.c  -fno-common -DPIC -o
> .libs/libopts_la-libopts.o
> 
> warning: unknown warning option '-Wno-format-contains-nul'
> [-Wunknown-warning-option]
> In file included from libopts.c:26:
> ./enum.c:112:38: warning: format string contains '\0' within the string
> body [-Wformat]
>             fprintf(option_usage_fp, ENUM_ERR_LINE, *(paz_names++));
>                                      ^~~~~~~~~~~~~
> ./ao-strs.h:70:31: note: expanded from macro 'ENUM_ERR_LINE'
> #define ENUM_ERR_LINE         (ao_strs_strtable+304)
>                               ^~~~~~~~~~~~~~~~~~~~~~
> ./ao-strs.c:90:20: note: format string is defined here
> /*   304 */ "  %s\n\0"
> ~~~~~~~~~~~~~~~~~~~^~~
> 
> 
> Did somebody go to a bunch of trouble to undo my work for the OS/X
> platform? :(

No, you are probably just using clang rather than gcc.
gcc has no -Wunknown-warning-option warning, -Wformat-contains-nul
is a known option and if you used some unknown -Wno-... warning option
and any diagnostics was emitted, the message would be just:
warning: unrecognized command line option ‘-Wno-whatever’

	Jakub

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: -Wno-format-contains-nul
  2018-06-20 18:40 ` -Wno-format-contains-nul Jakub Jelinek
@ 2018-06-20 18:48   ` Bruce Korb
  0 siblings, 0 replies; 3+ messages in thread
From: Bruce Korb @ 2018-06-20 18:48 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: GCC List

Thanks. I guess clang forked after the clever NUL-in-format-string was
added, but before my fix. :( I'll add -Wno-format if I can identify clang
over GCC.

On Wed, Jun 20, 2018 at 11:32 AM Jakub Jelinek <jakub@redhat.com> wrote:

> On Wed, Jun 20, 2018 at 11:17:50AM -0700, Bruce Korb wrote:
> > Years and years ago, I went to a mess of trouble to implement this
> > specialized warning so I would not have to see it anymore. I use a code
> > generator that puts constant strings into one huge buffer with all the
> > contained strings NUL separated.  Today, I was trying to build on OS/X:
> >
> > libtool: compile:  gcc -DHAVE_CONFIG_H -I. -I.. -I. -I../lib -g -O2
> > -Wcast-align -Wmissing-prototypes -Wpointer-arith -Wshadow
> > -Wstrict-prototypes -Wwrite-strings -Wno-format-contains-nul
> > -fno-strict-aliasing -Wstrict-aliasing=2 -MT libopts_la-libopts.lo -MD
> -MP
> > -MF .deps/libopts_la-libopts.Tpo -c libopts.c  -fno-common -DPIC -o
> > .libs/libopts_la-libopts.o
> >
> > warning: unknown warning option '-Wno-format-contains-nul'
> > [-Wunknown-warning-option]
> > In file included from libopts.c:26:
> > ./enum.c:112:38: warning: format string contains '\0' within the string
> > body [-Wformat]
> >             fprintf(option_usage_fp, ENUM_ERR_LINE, *(paz_names++));
> >                                      ^~~~~~~~~~~~~
> > ./ao-strs.h:70:31: note: expanded from macro 'ENUM_ERR_LINE'
> > #define ENUM_ERR_LINE         (ao_strs_strtable+304)
> >                               ^~~~~~~~~~~~~~~~~~~~~~
> > ./ao-strs.c:90:20: note: format string is defined here
> > /*   304 */ "  %s\n\0"
> > ~~~~~~~~~~~~~~~~~~~^~~
> >
> >
> > Did somebody go to a bunch of trouble to undo my work for the OS/X
> > platform? :(
>
> No, you are probably just using clang rather than gcc.
> gcc has no -Wunknown-warning-option warning, -Wformat-contains-nul
> is a known option and if you used some unknown -Wno-... warning option
> and any diagnostics was emitted, the message would be just:
> warning: unrecognized command line option ‘-Wno-whatever’
>
>         Jakub
>


-- 
 - Bruce

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-20 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-20 18:26 -Wno-format-contains-nul Bruce Korb
2018-06-20 18:40 ` -Wno-format-contains-nul Jakub Jelinek
2018-06-20 18:48   ` -Wno-format-contains-nul Bruce Korb

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).