diff mbox

fix profiledbootstrap with -Werror=format-length (77753)

Message ID 7bd66c78-14cb-0e07-a787-f89f02de95a7@gmail.com
State New
Headers show

Commit Message

Martin Sebor Sept. 27, 2016, 7:30 p.m. UTC
The attached one line patch increases a local buffer size to
avoid an apparently justified (though in reality likely a false
positive) -Wformat-length warning in varasm.c.  The warning has
been reported to break profiledbootstrap on powerp64le (though
not ordinary bootstrap).

An arguably better solution would be to explicitly constrain
the range of the integer variable to that of valid priority values.
Unfortunately, as pointed out in bug 77721, due to the limitation
of the current VRP implementation, this isn't always reliable.

Martin

Comments

Jeff Law Sept. 28, 2016, 4:38 a.m. UTC | #1
On 09/27/2016 01:30 PM, Martin Sebor wrote:
> The attached one line patch increases a local buffer size to
> avoid an apparently justified (though in reality likely a false
> positive) -Wformat-length warning in varasm.c.  The warning has
> been reported to break profiledbootstrap on powerp64le (though
> not ordinary bootstrap).
>
> An arguably better solution would be to explicitly constrain
> the range of the integer variable to that of valid priority values.
> Unfortunately, as pointed out in bug 77721, due to the limitation
> of the current VRP implementation, this isn't always reliable.
>
> Martin
>
> gcc-77753.diff
>
>
> PR bootstrap/77753 - [7 Regression] broken profiledbootstrap due to
> 	-Werror=format-length in varasm.c:1573
>
> gcc/ChangeLog:
> 2016-09-27  Martin Sebor  <msebor@redhat.com>
>
> 	PR bootstrap/77753
> 	* varasm.c (assemble_addr_to_section): Increase local buffer size.
OK.

WRT 77721, could you add that test to the testsuite, but xfailed?

Jeff
Martin Sebor Sept. 28, 2016, 7:55 p.m. UTC | #2
On 09/27/2016 10:38 PM, Jeff Law wrote:
> On 09/27/2016 01:30 PM, Martin Sebor wrote:
>> The attached one line patch increases a local buffer size to
>> avoid an apparently justified (though in reality likely a false
>> positive) -Wformat-length warning in varasm.c.  The warning has
>> been reported to break profiledbootstrap on powerp64le (though
>> not ordinary bootstrap).
>>
>> An arguably better solution would be to explicitly constrain
>> the range of the integer variable to that of valid priority values.
>> Unfortunately, as pointed out in bug 77721, due to the limitation
>> of the current VRP implementation, this isn't always reliable.
>>
>> Martin
>>
>> gcc-77753.diff
>>
>>
>> PR bootstrap/77753 - [7 Regression] broken profiledbootstrap due to
>>     -Werror=format-length in varasm.c:1573
>>
>> gcc/ChangeLog:
>> 2016-09-27  Martin Sebor  <msebor@redhat.com>
>>
>>     PR bootstrap/77753
>>     * varasm.c (assemble_addr_to_section): Increase local buffer size.
> OK.
>
> WRT 77721, could you add that test to the testsuite, but xfailed?

Sure.  Done in r240595.

Martin
diff mbox

Patch

PR bootstrap/77753 - [7 Regression] broken profiledbootstrap due to
	-Werror=format-length in varasm.c:1573

gcc/ChangeLog:
2016-09-27  Martin Sebor  <msebor@redhat.com>

	PR bootstrap/77753
	* varasm.c (assemble_addr_to_section): Increase local buffer size.

Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c	(revision 240556)
+++ gcc/varasm.c	(working copy)
@@ -1556,7 +1556,9 @@  assemble_addr_to_section (rtx symbol, se
 section *
 get_cdtor_priority_section (int priority, bool constructor_p)
 {
-  char buf[16];
+  /* Buffer conservatively large enough for the full range of a 32-bit
+     int plus the text below.  */
+  char buf[18];
 
   /* ??? This only works reliably with the GNU linker.  */
   sprintf (buf, "%s.%.5u",