public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
@ 2014-02-06  8:01 chengniansun at gmail dot com
  2014-02-06  8:27 ` [Bug c/60090] " mpolacek at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: chengniansun at gmail dot com @ 2014-02-06  8:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

            Bug ID: 60090
           Summary: For expression without ~, gcc -O1 emits "comparison of
                    promoted ~unsigned with unsigned"
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: chengniansun at gmail dot com

For the expression "(l ^ a) != b", gcc -O0 emits no warning, but gcc -O1 emits
a warning "comparison of promoted ~unsigned with unsigned". After checking the
gimple code, I found the optimization transforms the expression to a bitwise
not expression. 

However, in a syntactic perspective, the warning message is confusing, given
the fact that there is no '~' in this expression. 

$: cat s.c
int fn1(unsigned char a, unsigned char b) {
  const unsigned l = 4294967295u;
  return (l ^ a) != b;
}
$: gcc-trunk -c -Wsign-compare s.c
$: gcc-trunk -c -Wsign-compare s.c -O1
s.c: In function ‘fn1’:
s.c:3:18: warning: comparison of promoted ~unsigned with unsigned
[-Wsign-compare]
   return (l ^ a) != b;
                  ^
>From gcc-bugs-return-442784-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 06 08:10:09 2014
Return-Path: <gcc-bugs-return-442784-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6800 invoked by alias); 6 Feb 2014 08:10:08 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6750 invoked by uid 48); 6 Feb 2014 08:10:05 -0000
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ipa/59469] [4.8/4.9 Regression] LLVM build failure with gcc LTO
Date: Thu, 06 Feb 2014 08:10:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ipa
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: lto
X-Bugzilla-Severity: normal
X-Bugzilla-Who: hubicka at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.9.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-59469-4-h9ISaan9l4@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59469-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59469-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg00541.txt.bz2
Content-length: 342

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY469

--- Comment #45 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
The bug here is that lto-cgraph.c still checks DECL_COMDAT as a condition if
symbol is duplicated or partitioned.  We really need to get the logic into
lto-cgraph.c and use same test at both places... Will do that tomorrow.


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

* [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
  2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
@ 2014-02-06  8:27 ` mpolacek at gcc dot gnu.org
  2014-02-06  8:32 ` mpolacek at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-02-06  8:27 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-02-06
                 CC|                            |mpolacek at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This (and a bunch of other related PRs) is about early folding in the FE.  
c_fully_fold when optimize calls fold_build2 -> fold_binary_loc that transforms
the expression and then we issue those seemingly unrelated warnings.  I'd say
that while we want the exprs to be folded, we should issue diagnostics for the
unfolded exprs.  (I think it's been discussed numerous times in the past.)

Nothing for stage4, but we/I should address this in gcc 5.0.


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

* [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
  2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
  2014-02-06  8:27 ` [Bug c/60090] " mpolacek at gcc dot gnu.org
@ 2014-02-06  8:32 ` mpolacek at gcc dot gnu.org
  2014-02-06  9:42 ` mpolacek at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-02-06  8:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
C++ folds while parsing and here for both -O0 -O we get

y.c: In function ‘int fn1(unsigned char, unsigned char)’:
y.c:3:18: warning: comparison of promoted ~unsigned with unsigned
[-Wsign-compare]
   return (l ^ a) != b;
                  ^
>From gcc-bugs-return-442789-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 06 08:35:55 2014
Return-Path: <gcc-bugs-return-442789-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26538 invoked by alias); 6 Feb 2014 08:35:54 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 26513 invoked by uid 48); 6 Feb 2014 08:35:49 -0000
From: "chengniansun at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
Date: Thu, 06 Feb 2014 08:35:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: chengniansun at gmail dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-60090-4-mtVRwPv7jM@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60090-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60090-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg00546.txt.bz2
Content-length: 499

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`090

--- Comment #3 from Chengnian Sun <chengniansun at gmail dot com> ---
Thanks, Marek.

May I ask another question on the Gcc optimizations and warnings? Is there a
policy that the warnings should be independent of the optimization levels? That
is, for all optimization levels, Gcc should always emit consistent warnings.

I know that Clang has such a policy. But based on what I have observed on Gcc,
it seems that Gcc does not have this policy.


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

* [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
  2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
  2014-02-06  8:27 ` [Bug c/60090] " mpolacek at gcc dot gnu.org
  2014-02-06  8:32 ` mpolacek at gcc dot gnu.org
@ 2014-02-06  9:42 ` mpolacek at gcc dot gnu.org
  2014-02-06 12:54 ` manu at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-02-06  9:42 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
I believe we strive for the warnings be independent of the optimization level,
but it's not always possible, we have tons of bugs where -Wuninitialized
depends on the optimization level, sometimes -Warray-bounds warns only on -O3,
some warnings depend on VRP or SRA, on -O some uses are constant-propagated
etc.  In the middle-end we often warn only about variables in SSA form which
are made, as a part of some optimization, non-addressable.


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

* [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
  2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
                   ` (2 preceding siblings ...)
  2014-02-06  9:42 ` mpolacek at gcc dot gnu.org
@ 2014-02-06 12:54 ` manu at gcc dot gnu.org
  2014-02-06 13:04 ` mpolacek at gcc dot gnu.org
  2023-05-20  4:38 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: manu at gcc dot gnu.org @ 2014-02-06 12:54 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 3379 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #1)
> This (and a bunch of other related PRs) is about early folding in the FE.  
> c_fully_fold when optimize calls fold_build2 -> fold_binary_loc that
> transforms the expression and then we issue those seemingly unrelated
> warnings.  I'd say that while we want the exprs to be folded, we should
> issue diagnostics for the unfolded exprs.  (I think it's been discussed
> numerous times in the past.)
> 
> Nothing for stage4, but we/I should address this in gcc 5.0.

I think this should be the plan:

http://gcc.gnu.org/ml/gcc/2013-11/msg00253.html

but someone has to implement it ;-)

In those cases where folding helps to avoid false positives, it would be nice
to be able to still fold on-demand or to delay the warnings until folding can
happen.
>From gcc-bugs-return-442827-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 06 12:54:48 2014
Return-Path: <gcc-bugs-return-442827-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 8495 invoked by alias); 6 Feb 2014 12:54:48 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 8469 invoked by uid 48); 6 Feb 2014 12:54:45 -0000
From: "bernd.edlinger at hotmail dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug ada/60078] acats c761007 fails on ARM
Date: Thu, 06 Feb 2014 12:54:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: ada
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: bernd.edlinger at hotmail dot de
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-60078-4-vWURbZQ2ze@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60078-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60078-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg00584.txt.bz2
Content-length: 399

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`078

--- Comment #9 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 32065
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2065&actioníit
possible fix

well, I don't know if the Finalize method are supposed
to be called in a sequential manner, which GNAT does obviously not
guarantee.
But how about this, for a fix?


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

* [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
  2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
                   ` (3 preceding siblings ...)
  2014-02-06 12:54 ` manu at gcc dot gnu.org
@ 2014-02-06 13:04 ` mpolacek at gcc dot gnu.org
  2023-05-20  4:38 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-02-06 13:04 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 2701 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #5)
> http://gcc.gnu.org/ml/gcc/2013-11/msg00253.html

Exactly.  I hope I can tackle at least a part of it in next stage 1.

> In those cases where folding helps to avoid false positives, it would be nice
> to be able to still fold on-demand or to delay the warnings until folding can 
> happen.

Sure.
>From gcc-bugs-return-442831-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Feb 06 13:06:27 2014
Return-Path: <gcc-bugs-return-442831-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 21878 invoked by alias); 6 Feb 2014 13:06:26 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 21801 invoked by uid 48); 6 Feb 2014 13:06:21 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/60092] posix_memalign not recognized to derive alias and alignment info
Date: Thu, 06 Feb 2014 13:06:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: alias, missed-optimization
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: attachments.created
Message-ID: <bug-60092-4-ao4ecQGf4E@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60092-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60092-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-02/txt/msg00588.txt.bz2
Content-length: 375

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`092

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Created attachment 32066
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2066&actioníit
part #2, C11 aligned_alloc

It was noted that aligned_alloc is standard enough to be supported (and with
nicer interface albeit possibly clobbering errno ...).


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

* [Bug c/60090] For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned"
  2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
                   ` (4 preceding siblings ...)
  2014-02-06 13:04 ` mpolacek at gcc dot gnu.org
@ 2023-05-20  4:38 ` pinskia at gcc dot gnu.org
  5 siblings, 0 replies; 7+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-20  4:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60090

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This one still happens on the trunk even with PR 107465 fixed. The reason is
because even though a warning here is correct, it is not wanted due to
requiring constant folding. Note you can get also the incorrect warning wording
at -O0 with constexpr in GCC 13+ (and -std=c2x).

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

end of thread, other threads:[~2023-05-20  4:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-06  8:01 [Bug c/60090] New: For expression without ~, gcc -O1 emits "comparison of promoted ~unsigned with unsigned" chengniansun at gmail dot com
2014-02-06  8:27 ` [Bug c/60090] " mpolacek at gcc dot gnu.org
2014-02-06  8:32 ` mpolacek at gcc dot gnu.org
2014-02-06  9:42 ` mpolacek at gcc dot gnu.org
2014-02-06 12:54 ` manu at gcc dot gnu.org
2014-02-06 13:04 ` mpolacek at gcc dot gnu.org
2023-05-20  4:38 ` pinskia at gcc dot gnu.org

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