* [libibery PATCH] Fix bootstrap
@ 2017-05-25 0:56 Nathan Sidwell
2017-05-25 1:13 ` Nathan Sidwell
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2017-05-25 0:56 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 98 bytes --]
We now warn on casts to T const. Applied as obvious to fix bootstrap.
nathan
--
Nathan Sidwell
[-- Attachment #2: libiberty.diff --]
[-- Type: text/x-patch, Size: 970 bytes --]
Index: ChangeLog
===================================================================
--- ChangeLog (revision 248441)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2017-05-24 Nathan Sidwell <nathan@acm.org>
+
+ * libiberty.h (ASTRDUP): Adjust cast to avoid warning.
+
2017-05-19 Eli Zaretskii <eliz@gnu.org>
* environ.h: Add #ifndef guard.
Index: libiberty.h
===================================================================
--- libiberty.h (revision 248441)
+++ libiberty.h (working copy)
@@ -724,7 +724,7 @@ extern void *C_alloca (size_t) ATTRIBUTE
# define ASTRDUP(X) \
(__extension__ ({ const char *const libiberty_optr = (X); \
const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \
- char *const libiberty_nptr = (char *const) alloca (libiberty_len); \
+ char *const libiberty_nptr = (char *) alloca (libiberty_len); \
(char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
#else
# define alloca(x) C_alloca(x)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 0:56 [libibery PATCH] Fix bootstrap Nathan Sidwell
@ 2017-05-25 1:13 ` Nathan Sidwell
2017-05-25 1:22 ` Nathan Sidwell
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2017-05-25 1:13 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 174 bytes --]
On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
> We now warn on casts to T const. Applied as obvious to fix bootstrap.
And this fixes c-common.c
nathan
--
Nathan Sidwell
[-- Attachment #2: ccom.diff --]
[-- Type: text/x-patch, Size: 1107 bytes --]
2017-05-24 Nathan Sidwell <nathan@acm.org>
* c=common.c (field_decl_cmp, resort_field_decl_cmp): Adjust T
const casts to avoid warning.
Index: c-common.c
===================================================================
--- c-common.c (revision 248441)
+++ c-common.c (working copy)
@@ -5866,8 +5866,8 @@ check_builtin_function_arguments (locati
int
field_decl_cmp (const void *x_p, const void *y_p)
{
- const tree *const x = (const tree *const) x_p;
- const tree *const y = (const tree *const) y_p;
+ const tree *const x = (const tree *) x_p;
+ const tree *const y = (const tree *) y_p;
if (DECL_NAME (*x) == DECL_NAME (*y))
/* A nontype is "greater" than a type. */
@@ -5892,8 +5892,8 @@ pointer operator in resort_data. */
static int
resort_field_decl_cmp (const void *x_p, const void *y_p)
{
- const tree *const x = (const tree *const) x_p;
- const tree *const y = (const tree *const) y_p;
+ const tree *const x = (const tree *) x_p;
+ const tree *const y = (const tree *) y_p;
if (DECL_NAME (*x) == DECL_NAME (*y))
/* A nontype is "greater" than a type. */
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 1:13 ` Nathan Sidwell
@ 2017-05-25 1:22 ` Nathan Sidwell
2017-05-25 1:42 ` Nathan Sidwell
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2017-05-25 1:22 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 251 bytes --]
On 05/24/2017 08:56 PM, Nathan Sidwell wrote:
> On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
>> We now warn on casts to T const. Applied as obvious to fix bootstrap.
>
> And this fixes c-common.c
And fix auto-profile.c
nathan
--
Nathan Sidwell
[-- Attachment #2: ap.diff --]
[-- Type: text/x-patch, Size: 612 bytes --]
2017-05-24 Nathan Sidwell <nathan@acm.org>
* auto-profile.c (afdo_propagate): Adjust T const cast to avoid
warning.
Index: auto-profile.c
===================================================================
--- auto-profile.c (revision 248441)
+++ auto-profile.c (working copy)
@@ -1377,7 +1377,7 @@ afdo_propagate (bb_set *annotated_bb, ed
FOR_ALL_BB_FN (bb, cfun)
{
bb->count = ((basic_block)bb->aux)->count;
- if (is_bb_annotated ((const basic_block)bb->aux, *annotated_bb))
+ if (is_bb_annotated ((basic_block)bb->aux, *annotated_bb))
set_bb_annotated (bb, annotated_bb);
}
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 1:22 ` Nathan Sidwell
@ 2017-05-25 1:42 ` Nathan Sidwell
2017-05-25 6:25 ` Richard Biener
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2017-05-25 1:42 UTC (permalink / raw)
To: GCC Patches
[-- Attachment #1: Type: text/plain, Size: 328 bytes --]
On 05/24/2017 09:13 PM, Nathan Sidwell wrote:
> On 05/24/2017 08:56 PM, Nathan Sidwell wrote:
>> On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
>>> We now warn on casts to T const. Applied as obvious to fix bootstrap.
>>
>> And this fixes c-common.c
>
> And fix auto-profile.c
and lto-streamer-out.c, sigh
--
Nathan Sidwell
[-- Attachment #2: lto.diff --]
[-- Type: text/x-patch, Size: 615 bytes --]
2017-05-24 Nathan Sidwell <nathan@acm.org>
* lto-streamer-in.c (lto_input_data_block): Adjust T const cast to
avoid warning.
Index: lto-streamer-in.c
===================================================================
--- lto-streamer-in.c (revision 248441)
+++ lto-streamer-in.c (working copy)
@@ -86,7 +86,7 @@ void
lto_input_data_block (struct lto_input_block *ib, void *addr, size_t length)
{
size_t i;
- unsigned char *const buffer = (unsigned char *const) addr;
+ unsigned char *const buffer = (unsigned char *) addr;
for (i = 0; i < length; i++)
buffer[i] = streamer_read_uchar (ib);
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 1:42 ` Nathan Sidwell
@ 2017-05-25 6:25 ` Richard Biener
2017-05-25 10:58 ` Nathan Sidwell
0 siblings, 1 reply; 11+ messages in thread
From: Richard Biener @ 2017-05-25 6:25 UTC (permalink / raw)
To: gcc-patches, Nathan Sidwell, GCC Patches
On May 25, 2017 3:22:18 AM GMT+02:00, Nathan Sidwell <nathan@acm.org> wrote:
>On 05/24/2017 09:13 PM, Nathan Sidwell wrote:
>> On 05/24/2017 08:56 PM, Nathan Sidwell wrote:
>>> On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
>>>> We now warn on casts to T const. Applied as obvious to fix
>bootstrap.
>>>
>>> And this fixes c-common.c
>>
>> And fix auto-profile.c
>
>and lto-streamer-out.c, sigh
What's the reason to warn here?!
Richard.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 6:25 ` Richard Biener
@ 2017-05-25 10:58 ` Nathan Sidwell
2017-05-25 11:21 ` Jonathan Wakely
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2017-05-25 10:58 UTC (permalink / raw)
To: Richard Biener, gcc-patches; +Cc: Jonathan Wakely
On 05/25/2017 01:29 AM, Richard Biener wrote:
> On May 25, 2017 3:22:18 AM GMT+02:00, Nathan Sidwell <nathan@acm.org> wrote:
>> On 05/24/2017 09:13 PM, Nathan Sidwell wrote:
>>> On 05/24/2017 08:56 PM, Nathan Sidwell wrote:
>>>> On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
>>>>> We now warn on casts to T const. Applied as obvious to fix
>> bootstrap.
>>>>
>>>> And this fixes c-common.c
>>>
>>> And fix auto-profile.c
>>
>> and lto-streamer-out.c, sigh
>
> What's the reason to warn here?!
It's a new warning about trying to cast to a const T because the const
is ignored.
It might be better if the warning only triggered on trying to cast 'T'
to 'const T' and not trigger casting 'U' to 'const T'? I dunno.
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 10:58 ` Nathan Sidwell
@ 2017-05-25 11:21 ` Jonathan Wakely
2017-05-25 11:22 ` Jonathan Wakely
0 siblings, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2017-05-25 11:21 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: Richard Biener, gcc-patches
On 25/05/17 06:54 -0400, Nathan Sidwell wrote:
>On 05/25/2017 01:29 AM, Richard Biener wrote:
>>On May 25, 2017 3:22:18 AM GMT+02:00, Nathan Sidwell <nathan@acm.org> wrote:
>>>On 05/24/2017 09:13 PM, Nathan Sidwell wrote:
>>>>On 05/24/2017 08:56 PM, Nathan Sidwell wrote:
>>>>>On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
>>>>>>We now warn on casts to T const. Applied as obvious to fix
>>>bootstrap.
>>>>>
>>>>>And this fixes c-common.c
>>>>
>>>>And fix auto-profile.c
>>>
>>>and lto-streamer-out.c, sigh
>>
>>What's the reason to warn here?!
>
>It's a new warning about trying to cast to a const T because the const
>is ignored.
>
>It might be better if the warning only triggered on trying to cast 'T'
>to 'const T' and not trigger casting 'U' to 'const T'? I dunno.
Maybe, although the language is clear that casting to (const T) means
exactly the same as casting to (T) when T is a scalar type. What
benefit is there to saying (const T) if the compiler ignores the
const? (which the standard says it should, and I implemented in
r248432).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 11:21 ` Jonathan Wakely
@ 2017-05-25 11:22 ` Jonathan Wakely
2017-05-25 12:35 ` Nathan Sidwell
0 siblings, 1 reply; 11+ messages in thread
From: Jonathan Wakely @ 2017-05-25 11:22 UTC (permalink / raw)
To: Nathan Sidwell; +Cc: Richard Biener, gcc-patches
On 25/05/17 12:19 +0100, Jonathan Wakely wrote:
>On 25/05/17 06:54 -0400, Nathan Sidwell wrote:
>>On 05/25/2017 01:29 AM, Richard Biener wrote:
>>>On May 25, 2017 3:22:18 AM GMT+02:00, Nathan Sidwell <nathan@acm.org> wrote:
>>>>On 05/24/2017 09:13 PM, Nathan Sidwell wrote:
>>>>>On 05/24/2017 08:56 PM, Nathan Sidwell wrote:
>>>>>>On 05/24/2017 08:34 PM, Nathan Sidwell wrote:
>>>>>>>We now warn on casts to T const. Applied as obvious to fix
>>>>bootstrap.
>>>>>>
>>>>>>And this fixes c-common.c
>>>>>
>>>>>And fix auto-profile.c
>>>>
>>>>and lto-streamer-out.c, sigh
>>>
>>>What's the reason to warn here?!
>>
>>It's a new warning about trying to cast to a const T because the
>>const is ignored.
>>
>>It might be better if the warning only triggered on trying to cast
>>'T' to 'const T' and not trigger casting 'U' to 'const T'? I dunno.
>
>Maybe, although the language is clear that casting to (const T) means
>exactly the same as casting to (T) when T is a scalar type. What
>benefit is there to saying (const T) if the compiler ignores the
>const? (which the standard says it should, and I implemented in
>r248432).
I don't mind removing the warning again if preferred. I thought it was
useful (as we already warn for ignored const in return types).
All I really care about is that the compiler ignores the const, if it
does that without warning that's OK.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 11:22 ` Jonathan Wakely
@ 2017-05-25 12:35 ` Nathan Sidwell
2017-05-25 13:01 ` Richard Biener
0 siblings, 1 reply; 11+ messages in thread
From: Nathan Sidwell @ 2017-05-25 12:35 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Richard Biener, gcc-patches
On 05/25/2017 07:21 AM, Jonathan Wakely wrote:
> I don't mind removing the warning again if preferred. I thought it was
> useful (as we already warn for ignored const in return types).
Oh yeah, I recall noticing we did that (and noting we didn't warn
elsewhere). This new warning seems consistent.
I say leave it in unless the grumbling gets too much for you :)
nathan
--
Nathan Sidwell
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 12:35 ` Nathan Sidwell
@ 2017-05-25 13:01 ` Richard Biener
2017-05-25 13:03 ` Jonathan Wakely
0 siblings, 1 reply; 11+ messages in thread
From: Richard Biener @ 2017-05-25 13:01 UTC (permalink / raw)
To: Nathan Sidwell, Jonathan Wakely; +Cc: gcc-patches
On May 25, 2017 1:38:36 PM GMT+02:00, Nathan Sidwell <nathan@acm.org> wrote:
>On 05/25/2017 07:21 AM, Jonathan Wakely wrote:
>
>> I don't mind removing the warning again if preferred. I thought it
>was
>> useful (as we already warn for ignored const in return types).
>
>Oh yeah, I recall noticing we did that (and noting we didn't warn
>elsewhere). This new warning seems consistent.
>
>I say leave it in unless the grumbling gets too much for you :)
I wonder if we can somehow default to -Wno-error=xyz for such kind of 'style' warnings... Adding const can't possibly break anything or result in wrong expectations, can it?
Richard.
>nathan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [libibery PATCH] Fix bootstrap
2017-05-25 13:01 ` Richard Biener
@ 2017-05-25 13:03 ` Jonathan Wakely
0 siblings, 0 replies; 11+ messages in thread
From: Jonathan Wakely @ 2017-05-25 13:03 UTC (permalink / raw)
To: Richard Biener; +Cc: Nathan Sidwell, gcc-patches
On 25/05/17 14:35 +0200, Richard Biener wrote:
>On May 25, 2017 1:38:36 PM GMT+02:00, Nathan Sidwell <nathan@acm.org> wrote:
>>On 05/25/2017 07:21 AM, Jonathan Wakely wrote:
>>
>>> I don't mind removing the warning again if preferred. I thought it
>>was
>>> useful (as we already warn for ignored const in return types).
>>
>>Oh yeah, I recall noticing we did that (and noting we didn't warn
>>elsewhere). This new warning seems consistent.
>>
>>I say leave it in unless the grumbling gets too much for you :)
>
>I wonder if we can somehow default to -Wno-error=xyz for such kind of 'style' warnings... Adding const can't possibly break anything or result in wrong expectations, can it?
Now that G++ correctly ignores the const it can't change (or break)
anything to add const in the cast.
Before I fixed PR 80544, the presence/absence of the const affected
the generated code and could result in e.g. different overloaded
functions being called (in some fairly obscure cases).
The original report I got was http://ideone.com/JSFEZ3 and GCC was
giving different behaviour to all other C++ compilers (which ignored
the const and so failed the static assertion).
The warning is just saying "hey, you know what you wrote is going to
be ignored, right?" That's a bit like "statement has no effect"
warnings, although those warnings are usually because you mistyped
something and so find real bugs.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2017-05-25 13:01 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-25 0:56 [libibery PATCH] Fix bootstrap Nathan Sidwell
2017-05-25 1:13 ` Nathan Sidwell
2017-05-25 1:22 ` Nathan Sidwell
2017-05-25 1:42 ` Nathan Sidwell
2017-05-25 6:25 ` Richard Biener
2017-05-25 10:58 ` Nathan Sidwell
2017-05-25 11:21 ` Jonathan Wakely
2017-05-25 11:22 ` Jonathan Wakely
2017-05-25 12:35 ` Nathan Sidwell
2017-05-25 13:01 ` Richard Biener
2017-05-25 13:03 ` Jonathan Wakely
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).