diff mbox

[C++] PR 50956

Message ID 4EB1819C.6080800@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Nov. 2, 2011, 5:45 p.m. UTC
... ehm, we use -Wcast-qual during the bootstrap, thus if I don't want 
to break it again, better doing the below too. Seems obvious, by itself.

Paolo.

//////////////////
2011-11-02  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50956
	* builtins.c (fold_builtin_memchr): Fix cast.

Comments

Jason Merrill Nov. 2, 2011, 6:26 p.m. UTC | #1
On 11/02/2011 01:45 PM, Paolo Carlini wrote:
> ... ehm, we use -Wcast-qual during the bootstrap, thus if I don't want
> to break it again, better doing the below too. Seems obvious, by itself.

Yep.

Jason
Paolo Carlini Nov. 2, 2011, 6:48 p.m. UTC | #2
On 11/02/2011 07:26 PM, Jason Merrill wrote:
> On 11/02/2011 01:45 PM, Paolo Carlini wrote:
>> ... ehm, we use -Wcast-qual during the bootstrap, thus if I don't want
>> to break it again, better doing the below too. Seems obvious, by itself.
> Yep.
Great, all done. Note for the accidental reader: it's indeed obvious, 
but only if you are used to the C++ memchr, the two overloads. For the 
targets (many outside Linux) not providing those (via libc hooks) I 
would not have broken the bootstrap ;)

Paolo.
Jason Merrill Nov. 2, 2011, 7:12 p.m. UTC | #3
Another bootstrap issue:

In file included from /home/jason/src/trunk/gcc/fortran/cpp.c:35:0:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h: In function 
‘unsigned char* ustrchr(const unsigned char*, int)’:
/home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h:782:55: error: 
cast from type ‘const char*’ to type ‘unsigned char*’ casts away 
qualifiers [-Werror=cast-qual]
Paolo Carlini Nov. 2, 2011, 7:44 p.m. UTC | #4
On 11/02/2011 08:12 PM, Jason Merrill wrote:
> Another bootstrap issue:
>
> In file included from /home/jason/src/trunk/gcc/fortran/cpp.c:35:0:
> /home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h: In function 
> ‘unsigned char* ustrchr(const unsigned char*, int)’:
> /home/jason/src/trunk/gcc/fortran/../../libcpp/internal.h:782:55: 
> error: cast from type ‘const char*’ to type ‘unsigned char*’ casts 
> away qualifiers [-Werror=cast-qual]
Argh, I'll fix it momentarily.

Paolo.
diff mbox

Patch

Index: builtins.c
===================================================================
--- builtins.c	(revision 180778)
+++ builtins.c	(working copy)
@@ -8427,7 +8427,7 @@  fold_builtin_memchr (location_t loc, tree arg1, tr
 	  if (target_char_cast (arg2, &c))
 	    return NULL_TREE;
 
-	  r = (char *) memchr (p1, c, tree_low_cst (len, 1));
+	  r = (const char *) memchr (p1, c, tree_low_cst (len, 1));
 
 	  if (r == NULL)
 	    return build_int_cst (TREE_TYPE (arg1), 0);