public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Avoid -Werror=format-overflow error in dbxout.c (dbxout_block) on Solaris/SPARC
@ 2017-12-04 12:41 Rainer Orth
  2017-12-04 19:18 ` Martin Sebor
  2017-12-04 19:35 ` Jeff Law
  0 siblings, 2 replies; 7+ messages in thread
From: Rainer Orth @ 2017-12-04 12:41 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eric Botcazou

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

Within test last week, 64-bit Solaris/SPARC bootstrap began to fail:

/vol/gcc/src/hg/trunk/local/gcc/dbxout.c: In function 'bool dbxout_block(tree, int, tree, int)':
/vol/gcc/src/hg/trunk/local/gcc/dbxout.c:3767:1: error: '%lu' directive writing between 1 and 20 bytes into a region of size 14 [-Werror=format-overflow=]
 dbxout_block (tree block, int depth, tree args, int parent_blocknum)
 ^~~~~~~~~~~~
/vol/gcc/src/hg/trunk/local/gcc/dbxout.c:3767:1: note: directive argument in the range [0, 18446744073709551614]
In file included from ./tm.h:26,
                 from /vol/gcc/src/hg/trunk/local/gcc/target.h:52,
                 from /vol/gcc/src/hg/trunk/local/gcc/dbxout.c:72:
/vol/gcc/src/hg/trunk/local/gcc/config/sparc/sol2.h:353:11: note: 'std::sprintf' output between 8 and 27 bytes into a destination of size 20
   sprintf ((LABEL), "*.L%s%lu", (PREFIX), (unsigned long)(NUM))
   ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/gcc/src/hg/trunk/local/gcc/dbxout.c:3855:5: note: in expansion of macro 'ASM_GENERATE_INTERNAL_LABEL'
     ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", parent_blocknum);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~

The line numbers are extremely confusing, to say the least, though: the
one in the error and the first note refer to the begin of the function
definition and only the third note refers to the line of the actual
error.

Fixed as follows, which allowed sparcv9-sun-solaris2.11 bootstrap to
finish and passed regtest on sparc-sun-solaris2.11.

Ok for mainline?

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University


2017-12-04  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	* dbxout.c (dbxout_block): Grow buf to 30 bytes.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sol2-dbxout-format-overflow.patch --]
[-- Type: text/x-patch, Size: 410 bytes --]

diff --git a/gcc/dbxout.c b/gcc/dbxout.c
--- a/gcc/dbxout.c
+++ b/gcc/dbxout.c
@@ -3844,7 +3844,7 @@ dbxout_block (tree block, int depth, tre
 	      /* If we emitted any vars and didn't output any LBRAC/RBRAC,
 		 either at this level or any lower level, we need to emit
 		 an empty LBRAC/RBRAC pair now.  */
-	      char buf[20];
+	      char buf[30];
 	      const char *scope_start;
 
 	      ret = true;

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

end of thread, other threads:[~2017-12-08 22:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04 12:41 Avoid -Werror=format-overflow error in dbxout.c (dbxout_block) on Solaris/SPARC Rainer Orth
2017-12-04 19:18 ` Martin Sebor
2017-12-04 20:58   ` David Malcolm
2017-12-05  1:05     ` Martin Sebor
2017-12-08 21:34       ` David Malcolm
2017-12-08 22:20         ` Martin Sebor
2017-12-04 19:35 ` Jeff Law

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