diff mbox

[PING,2] c++/67942 - diagnose placement new buffer overflow

Message ID yddoaf7479d.fsf@CeBiTec.Uni-Bielefeld.DE
State New
Headers show

Commit Message

Rainer Orth Nov. 6, 2015, 12:55 p.m. UTC
Martin Sebor <msebor@gmail.com> writes:

>> If we use gcc_checking_assert it won't fire in release builds; let's go
>> with that.
>
> Okay. Attached is an updated patch with that change.

Unfortunately, this breaks i386-pc-solaris2.10 bootstrap:

/vol/gcc/src/hg/trunk/local/gcc/cp/init.c: In function 'void warn_placement_new_too_small(tree, tree, tree, tree)':
/vol/gcc/src/hg/trunk/local/gcc/cp/init.c:2454:17: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'long long unsigned int' [-Werror=format=]
      bytes_avail);
                 ^

Printing an unsigned HOST_WIDE_INT with %lu in one case, but %wu in the
other seems like a simple typo, so the following fixes bootstrap for me:
Rainer

Comments

Martin Sebor Nov. 6, 2015, 3:28 p.m. UTC | #1
On 11/06/2015 05:55 AM, Rainer Orth wrote:
> Martin Sebor <msebor@gmail.com> writes:
>
>>> If we use gcc_checking_assert it won't fire in release builds; let's go
>>> with that.
>>
>> Okay. Attached is an updated patch with that change.
>
> Unfortunately, this breaks i386-pc-solaris2.10 bootstrap:
>
> /vol/gcc/src/hg/trunk/local/gcc/cp/init.c: In function 'void warn_placement_new_too_small(tree, tree, tree, tree)':
> /vol/gcc/src/hg/trunk/local/gcc/cp/init.c:2454:17: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'long long unsigned int' [-Werror=format=]
>        bytes_avail);
>                   ^
>
> Printing an unsigned HOST_WIDE_INT with %lu in one case, but %wu in the
> other seems like a simple typo, so the following fixes bootstrap for me:

Yes, that was a typo. Sorry about that and thanks to ktkachov for
committing the fix!

Martin
diff mbox

Patch

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2447,7 +2447,7 @@  warn_placement_new_too_small (tree type,
 			  "%<%T [%wu]%> and size %qwu in a region of type %qT "
 			  "and size %qwi"
 			  : "placement new constructing an object of type "
-			  "%<%T [%lu]%> and size %qwu in a region of type %qT "
+			  "%<%T [%wu]%> and size %qwu in a region of type %qT "
 			  "and size at most %qwu",
 			  type, tree_to_uhwi (nelts), bytes_need,
 			  TREE_TYPE (oper),