public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Error building gcc master: gcc/opts.cc: -Werror=format-truncation
@ 2023-03-15 18:15 Alejandro Colomar
  2023-03-15 19:06 ` Jonathan Wakely
  0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2023-03-15 18:15 UTC (permalink / raw)
  To: gcc-help


[-- Attachment #1.1: Type: text/plain, Size: 2909 bytes --]

Hi,

I'm getting this error while building GCC from the master branch:

alx@debian:~/src/gnu/gcc/.tmp$ make 'BOOT_CFLAGS=-march=native' bootstrap
[...]
/home/alx/src/gnu/gcc/.tmp/./prev-gcc/xg++ -B/home/alx/src/gnu/gcc/.tmp/./prev-gcc/ -B/opt/gnu/gcc/alx/Wusi/1/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -I/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu  -I/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/include  -I/home/alx/src/gnu/gcc/libstdc++-v3/libsupc++ -L/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -fno-PIE -c   -march=native -fno-checking -gtoggle -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common  -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include  -I../../gcc/../libcpp/include -I../../gcc/../libcody  -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace   -o opts.o -MT opts.o -MMD -MP -MF ./.deps/opts.TPo ../../gcc/opts.cc
../../gcc/opts.cc: In function ‘void print_filtered_help(unsigned int, unsigned int, unsigned int, unsigned int, gcc_options*, unsigned int)’:
../../gcc/opts.cc:1685:26: error: ‘  ’ directive output may be truncated writing 2 bytes into a region of size between 1 and 256 [-Werror=format-truncation=]
 1685 |                       "%s  %s", help, _(use_diagnosed_msg));
      |                          ^~
../../gcc/opts.cc:1684:22: note: ‘snprintf’ output 3 or more bytes (assuming 258) into a destination of size 256
 1684 |             snprintf (new_help, sizeof new_help,
      |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 1685 |                       "%s  %s", help, _(use_diagnosed_msg));
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[3]: *** [Makefile:1152: opts.o] Error 1


My system is Debian Sid, and GCC 12.2.0:
$ gcc --version
gcc (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


Is it some known issue?  I was trying to test a patch I'm developing,
but I can't even build from master.

Thanks,

Alex


-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Error building gcc master: gcc/opts.cc: -Werror=format-truncation
  2023-03-15 18:15 Error building gcc master: gcc/opts.cc: -Werror=format-truncation Alejandro Colomar
@ 2023-03-15 19:06 ` Jonathan Wakely
  2023-03-16  3:17   ` Xi Ruoyao
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2023-03-15 19:06 UTC (permalink / raw)
  To: Alejandro Colomar; +Cc: gcc-help

[-- Attachment #1: Type: text/plain, Size: 3037 bytes --]

On Wed, 15 Mar 2023, 18:17 Alejandro Colomar via Gcc-help, <
gcc-help@gcc.gnu.org> wrote:

> Hi,
>
> I'm getting this error while building GCC from the master branch:
>
> alx@debian:~/src/gnu/gcc/.tmp$ make 'BOOT_CFLAGS=-march=native' bootstrap
> [...]
> /home/alx/src/gnu/gcc/.tmp/./prev-gcc/xg++
> -B/home/alx/src/gnu/gcc/.tmp/./prev-gcc/
> -B/opt/gnu/gcc/alx/Wusi/1/x86_64-pc-linux-gnu/bin/ -nostdinc++
> -B/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs
> -B/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs
> -I/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu
> -I/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/include
> -I/home/alx/src/gnu/gcc/libstdc++-v3/libsupc++
> -L/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs
> -L/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs
> -fno-PIE -c   -march=native -fno-checking -gtoggle -DIN_GCC
>  -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall
> -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute
> -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long
> -Wno-variadic-macros -Wno-overlength-strings -Werror -fno-common
> -DHAVE_CONFIG_H -I. -I. -I../../gcc -I../../gcc/. -I../../gcc/../include
> -I../../gcc/../libcpp/include -I../../gcc/../libcody
> -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid
> -I../libdecnumber -I../../gcc/../libbacktrace   -o opts.o -MT opts.o -MMD
> -MP -MF ./.deps/opts.TPo ../../gcc/opts.cc
> ../../gcc/opts.cc: In function ‘void print_filtered_help(unsigned int,
> unsigned int, unsigned int, unsigned int, gcc_options*, unsigned int)’:
> ../../gcc/opts.cc:1685:26: error: ‘  ’ directive output may be truncated
> writing 2 bytes into a region of size between 1 and 256
> [-Werror=format-truncation=]
>  1685 |                       "%s  %s", help, _(use_diagnosed_msg));
>       |                          ^~
> ../../gcc/opts.cc:1684:22: note: ‘snprintf’ output 3 or more bytes
> (assuming 258) into a destination of size 256
>  1684 |             snprintf (new_help, sizeof new_help,
>       |             ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1685 |                       "%s  %s", help, _(use_diagnosed_msg));
>       |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> cc1plus: all warnings being treated as errors
> make[3]: *** [Makefile:1152: opts.o] Error 1
>
>
> My system is Debian Sid, and GCC 12.2.0:
> $ gcc --version
> gcc (Debian 12.2.0-14) 12.2.0
> Copyright (C) 2022 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>
> Is it some known issue?  I was trying to test a patch I'm developing,
> but I can't even build from master.
>


--disable-werror should work around it.

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

* Re: Error building gcc master: gcc/opts.cc: -Werror=format-truncation
  2023-03-15 19:06 ` Jonathan Wakely
@ 2023-03-16  3:17   ` Xi Ruoyao
  2023-03-16  3:50     ` Alejandro Colomar
  0 siblings, 1 reply; 5+ messages in thread
From: Xi Ruoyao @ 2023-03-16  3:17 UTC (permalink / raw)
  To: Jonathan Wakely, Alejandro Colomar; +Cc: gcc-help

On Wed, 2023-03-15 at 19:06 +0000, Jonathan Wakely via Gcc-help wrote:
> On Wed, 15 Mar 2023, 18:17 Alejandro Colomar via Gcc-help, <
> gcc-help@gcc.gnu.org> wrote:
> 
> > Hi,
> > 
> > I'm getting this error while building GCC from the master branch:
> > 
> > alx@debian:~/src/gnu/gcc/.tmp$ make 'BOOT_CFLAGS=-march=native' bootstrap

/* snip */

> --disable-werror should work around it.

FWIW if you are altering BOOT_CFLAGS, it will be more likely you'll need
--disable-werror than a "plain" build.

And it seems you are altering BOOT_CFLAGS in a wrong way.  AFAIK you
need 'BOOT_CFLAGS="-march=native -O2"' or you are removing the default -
O2 flag.  The result will be slower.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

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

* Re: Error building gcc master: gcc/opts.cc: -Werror=format-truncation
  2023-03-16  3:17   ` Xi Ruoyao
@ 2023-03-16  3:50     ` Alejandro Colomar
  2023-03-17  1:10       ` Alejandro Colomar
  0 siblings, 1 reply; 5+ messages in thread
From: Alejandro Colomar @ 2023-03-16  3:50 UTC (permalink / raw)
  To: Xi Ruoyao, Jonathan Wakely; +Cc: gcc-help


[-- Attachment #1.1: Type: text/plain, Size: 6045 bytes --]

Hi Xi, Jonathan,

On 3/16/23 04:17, Xi Ruoyao wrote:
> On Wed, 2023-03-15 at 19:06 +0000, Jonathan Wakely via Gcc-help wrote:
>> On Wed, 15 Mar 2023, 18:17 Alejandro Colomar via Gcc-help, <
>> gcc-help@gcc.gnu.org> wrote:
>>
>>> Hi,
>>>
>>> I'm getting this error while building GCC from the master branch:
>>>
>>> alx@debian:~/src/gnu/gcc/.tmp$ make 'BOOT_CFLAGS=-march=native' bootstrap
> 
> /* snip */
> 
>> --disable-werror should work around it.

I added that.

> 
> FWIW if you are altering BOOT_CFLAGS, it will be more likely you'll need
> --disable-werror than a "plain" build.
> 
> And it seems you are altering BOOT_CFLAGS in a wrong way.  AFAIK you
> need 'BOOT_CFLAGS="-march=native -O2"' or you are removing the default -
> O2 flag.  The result will be slower.

Hmm, thanks.  Then removed that too.

And I still get issues.  Now it's undefined references.  Let me show
the commands:


$ history
[...]
 1995  ../configure --with-pkgversion=alx-wusi_1 --prefix=/opt/local/gnu/gcc/wusi/1 --disable-werror --disable-multilib
 1996  make bootstrap -j8
 1997  touch gcc/c-family/c.opt gcc/c/c-typeck.cc
 1998  make bootstrap


And here's are the first errors of `make bootstrap`:
[...]
/home/alx/src/gnu/gcc/.tmp/./prev-gcc/xg++ -B/home/alx/src/gnu/gcc/.tmp/./prev-gcc/ -B/opt/local/gnu/gcc/wusi/1/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/alx/src/gnu/gcc/.tmp/prev-x86_64-
pc-linux-gnu/libstdc++-v3/src/.libs -B/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -I/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/inc
lude/x86_64-pc-linux-gnu  -I/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/include  -I/home/alx/src/gnu/gcc/libstdc++-v3/libsupc++ -L/home/alx/src/gnu/gcc/.tmp/prev-x86_64-
pc-linux-gnu/libstdc++-v3/src/.libs -L/home/alx/src/gnu/gcc/.tmp/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs -no-pie   -g -O2 -fchecking=1 -DIN_GCC     -fno-exceptions -fno-rtti -f
asynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadi
c-macros -Wno-overlength-strings -fno-common  -DHAVE_CONFIG_H -static-libstdc++ -static-libgcc  -o cc1 c/c-lang.o c-family/stub-objc.o attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o c/c-conv
ert.o c/c-aux-info.o c/c-objc-common.o c/c-parser.o c/c-fold.o c/gimple-parser.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o c-family/c-format.o c-family/c-gimplify.o c-fam
ily/c-indentation.o c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o c-family/c-semantics.o c-family/c
-ada-spec.o c-family/c-ubsan.o c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o c-family/c-spellcheck.o i386-c.o glibc-c.o \
  cc1-checksum.o libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a ../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a   ../libbacktrace/.libs/libbacktrace.a ..
/libiberty/libiberty.a ../libdecnumber/libdecnumber.a   -lmpc -lmpfr -lgmp -rdynamic  -L./../zlib -lz -lzstd 
/usr/bin/ld: c/c-decl.o: in function `warn_if_shadowing(tree_node*)':
/home/alx/src/gnu/gcc/.tmp/gcc/../../gcc/c/c-decl.cc:3137: undefined reference to `comptypes(tree_node*, tree_node*)'
/usr/bin/ld: c/c-decl.o: in function `warn_if_shadowing':
/home/alx/src/gnu/gcc/.tmp/gcc/../../gcc/c/c-decl.cc:3176: undefined reference to `comptypes(tree_node*, tree_node*)'
/usr/bin/ld: c/c-decl.o: in function `diagnose_mismatched_decls(tree_node*, tree_node*, tree_node**, tree_node**) [clone .constprop.0]':
/home/alx/src/gnu/gcc/.tmp/gcc/../../gcc/c/c-decl.cc:2076: undefined reference to `comptypes_check_enum_int(tree_node*, tree_node*, bool*)'
/usr/bin/ld: /home/alx/src/gnu/gcc/.tmp/gcc/../../gcc/c/c-decl.cc:2238: undefined reference to `comptypes_check_different_types(tree_node*, tree_node*, bool*)'
/usr/bin/ld: /home/alx/src/gnu/gcc/.tmp/gcc/../../gcc/c/c-decl.cc:1884: undefined reference to `comptypes(tree_node*, tree_node*)'


Admittedly, this time I tried already with my patch applied, but I don't
think they have any relation with the error.

Do you know what might be wrong?

Thanks,

Alex

---

The patch I'm trying is simple:


commit 82432cdda2bb968a0dfe8a357ec03cce400ac8f1 (HEAD -> Wunterminated-string-initialization)
Author: Alejandro Colomar <alx@kernel.org>
Date:   Wed Mar 15 17:00:15 2023 +0100

    Wunterminated-string-initialization

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 3333cddeece..0a250593112 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1382,6 +1382,10 @@ Wunsuffixed-float-constants
 C ObjC Var(warn_unsuffixed_float_constants) Warning
 Warn about unsuffixed float constants.
 
+Wunterminated-string-initialization
+C C++ Var(warn_unterminated_string_initialization) Warning LangEnabledBy(C,Wextra || Wc++-compat)
+Warn about character arrays initialized as unterminated strings by a string literal.
+
 Wunused
 C ObjC C++ ObjC++ LangEnabledBy(C ObjC C++ ObjC++,Wall)
 ; documented in common.opt
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 45bacc06c47..2ae86b247c6 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -8420,7 +8420,7 @@ digest_init (location_t init_loc, tree type, tree init, tree origtype,
                pedwarn_init (init_loc, 0,
                              ("initializer-string for array of %qT "
                               "is too long"), typ1);
-             else if (warn_cxx_compat
+             else if (warn_unterminated_string_initialization
                       && compare_tree_int (TYPE_SIZE_UNIT (type), len) < 0)
                warning_at (init_loc, OPT_Wc___compat,
                            ("initializer-string for array of %qT "


-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: Error building gcc master: gcc/opts.cc: -Werror=format-truncation
  2023-03-16  3:50     ` Alejandro Colomar
@ 2023-03-17  1:10       ` Alejandro Colomar
  0 siblings, 0 replies; 5+ messages in thread
From: Alejandro Colomar @ 2023-03-17  1:10 UTC (permalink / raw)
  To: Xi Ruoyao, Jonathan Wakely; +Cc: gcc-help


[-- Attachment #1.1: Type: text/plain, Size: 909 bytes --]

Hi Xi, Jonathan,

On 3/16/23 04:50, Alejandro Colomar wrote:
>>
>>> --disable-werror should work around it.
> 
> I added that.
> 
>>
>> FWIW if you are altering BOOT_CFLAGS, it will be more likely you'll need
>> --disable-werror than a "plain" build.
>>
>> And it seems you are altering BOOT_CFLAGS in a wrong way.  AFAIK you
>> need 'BOOT_CFLAGS="-march=native -O2"' or you are removing the default -
>> O2 flag.  The result will be slower.
> 
> Hmm, thanks.  Then removed that too.
> 
> And I still get issues.  Now it's undefined references.

My bad.  I built in a subdirectory of the source dir, which is
explicitly unsupported, and is a FAQ.  I didn't read part correctly
in the manual.  :-)

I've been able to test my patch and will be sending it soon.

Cheers,

Alex

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2023-03-17  1:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15 18:15 Error building gcc master: gcc/opts.cc: -Werror=format-truncation Alejandro Colomar
2023-03-15 19:06 ` Jonathan Wakely
2023-03-16  3:17   ` Xi Ruoyao
2023-03-16  3:50     ` Alejandro Colomar
2023-03-17  1:10       ` Alejandro Colomar

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).