public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/37038]  New: Bogus warning from GCC
@ 2008-08-06 14:49 sam at gcc dot gnu dot org
  2008-08-06 14:50 ` [Bug ada/37038] " sam at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-08-06 14:49 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1372 bytes --]

With trunk GCC, SVN revision 138798.

The following program (t.adb), when compiled with "gcc -O2", gives:

t.adb: In function ‘T’:
t.adb:6: warning: comparison always false due to limited range of data type

(probably emitted by the backend as "-gnatv" doesn't show the caret position)

Note that the warning points onto the line containing 'Pos, not the comparison
itself. And this is bogus, as if "X" contains "2#11xxxxxx#" (two high bits
set), then right shifting it by 6 positions (it is unsigned) will give "3",
which corresponds to "White".

Moreover, despites the warning, the generated code is correct and returns "0"
when the two high bits are set and "1" otherwise.

with Interfaces; use Interfaces;

function T (X : Unsigned_8) return Integer
is
   type Color is (None, Red, Blue, White);
   V : constant Color := Color'Val (Shift_Right (X, 6));
begin
   if V = White then
      return 0;
   else
      return 1;
   end if;
end T;


-- 
           Summary: Bogus warning from GCC
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sam at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
@ 2008-08-06 14:50 ` sam at gcc dot gnu dot org
  2008-08-06 15:40 ` sam at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-08-06 14:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from sam at gcc dot gnu dot org  2008-08-06 14:49 -------
(read "the line containing 'Val", not "'Pos")


-- 


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
  2008-08-06 14:50 ` [Bug ada/37038] " sam at gcc dot gnu dot org
@ 2008-08-06 15:40 ` sam at gcc dot gnu dot org
  2008-08-06 15:46   ` Andrew Thomas Pinski
  2008-08-06 15:47 ` pinskia at gmail dot com
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-08-06 15:40 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from sam at gcc dot gnu dot org  2008-08-06 15:39 -------
The warning comes from a range check which is emitted by Gigi. The backend
knows that this check is useless, and warns about it. As far as I can tell,
there is no way to suppress the warning in shorten_compare (c-common.c), except
by setting a global option (OPT_Wtype_limits) to false.


-- 


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


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

* Re: [Bug ada/37038] Bogus warning from GCC
  2008-08-06 15:40 ` sam at gcc dot gnu dot org
@ 2008-08-06 15:46   ` Andrew Thomas Pinski
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Thomas Pinski @ 2008-08-06 15:46 UTC (permalink / raw)
  To: gcc-bugzilla; +Cc: gcc-bugs



Sent from my iPhone

On Aug 6, 2008, at 8:39, "sam at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #2 from sam at gcc dot gnu dot org  2008-08-06 15:39  
> -------
> The warning comes from a range check which is emitted by Gigi. The  
> backend
> knows that this check is useless, and warns about it. As far as I  
> can tell,
> there is no way to suppress the warning in shorten_compare (c- 
> common.c), except
> by setting a global option (OPT_Wtype_limits) to false.

C-common.c being included by the Ada front-end???? That is a c front- 
end file.

-- Pinski


>
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37038
>


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
  2008-08-06 14:50 ` [Bug ada/37038] " sam at gcc dot gnu dot org
  2008-08-06 15:40 ` sam at gcc dot gnu dot org
@ 2008-08-06 15:47 ` pinskia at gmail dot com
  2008-08-06 16:58 ` sam at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: pinskia at gmail dot com @ 2008-08-06 15:47 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gmail dot com  2008-08-06 15:46 -------
Subject: Re:  Bogus warning from GCC



Sent from my iPhone

On Aug 6, 2008, at 8:39, "sam at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org 
 > wrote:

>
>
> ------- Comment #2 from sam at gcc dot gnu dot org  2008-08-06 15:39  
> -------
> The warning comes from a range check which is emitted by Gigi. The  
> backend
> knows that this check is useless, and warns about it. As far as I  
> can tell,
> there is no way to suppress the warning in shorten_compare (c- 
> common.c), except
> by setting a global option (OPT_Wtype_limits) to false.

C-common.c being included by the Ada front-end???? That is a c front- 
end file.

-- Pinski


>
>
>
> -- 
>
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37038
>


-- 


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2008-08-06 15:47 ` pinskia at gmail dot com
@ 2008-08-06 16:58 ` sam at gcc dot gnu dot org
  2008-08-10 20:18 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-08-06 16:58 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from sam at gcc dot gnu dot org  2008-08-06 16:57 -------
Andrew, you're right, I got confused by the build_binary_op() which is present
both in ada/gcc-interface/utils2.c and c-typeck.c, and that the warning appears
as is in c-common.c.

The warning is likely to come from tree-vrp.c.


-- 


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2008-08-06 16:58 ` sam at gcc dot gnu dot org
@ 2008-08-10 20:18 ` pinskia at gcc dot gnu dot org
  2008-08-10 20:32 ` sam at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-10 20:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pinskia at gcc dot gnu dot org  2008-08-10 20:17 -------
(In reply to comment #4)
> The warning is likely to come from tree-vrp.c.

The only place which emits this warning is from c-common.c so I think someone
needs to debug this a little bit.  Place a breakpoint on warning and then look
at the backtrace to figure out where the warning is coming from.  If it is
truly coming from c-common.c, then the Ada front-end is wrong to include that
source at all.


-- 


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2008-08-10 20:18 ` pinskia at gcc dot gnu dot org
@ 2008-08-10 20:32 ` sam at gcc dot gnu dot org
  2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2008-08-10 20:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from sam at gcc dot gnu dot org  2008-08-10 20:30 -------
Subject: Re:  Bogus warning from GCC

>> The warning is likely to come from tree-vrp.c.

> The only place which emits this warning is from c-common.c so I
> think someone needs to debug this a little bit.  Place a breakpoint
> on warning and then look at the backtrace to figure out where the
> warning is coming from.  If it is truly coming from c-common.c, then
> the Ada front-end is wrong to include that source at all.

As I wrote, it must be coming from tree-vrp.c: the warning message is
split on two lines there, which is why I didn't catch it either the
first time I looked for it.


-- 


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
@ 2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
  2009-10-06 11:37 ` sam at gcc dot gnu dot org
  2009-10-06 11:37 ` sam at gcc dot gnu dot org
  9 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-10 20:36 UTC (permalink / raw)
  To: gcc-bugs



-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-08-10 20:35:03
               date|                            |


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2008-08-10 20:32 ` sam at gcc dot gnu dot org
@ 2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
  2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-08-10 20:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pinskia at gcc dot gnu dot org  2008-08-10 20:34 -------
Oh I see it now:
      /* If the comparison is being folded and the operand on the LHS
         is being compared against a constant value that is outside of
         the natural range of OP0's type, then the predicate will
         always fold regardless of the value of OP0.  If -Wtype-limits
         was specified, emit a warning.  */

So the trick should be is set TREE_NO_WARNING on the comparison in the
front-end and then have VRP check that (if it is possible to do so now after
the tuples merge :( ).


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dnovillo at gcc dot gnu dot
                   |                            |org


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (7 preceding siblings ...)
  2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
@ 2009-10-06 11:37 ` sam at gcc dot gnu dot org
  2009-10-06 11:37 ` sam at gcc dot gnu dot org
  9 siblings, 0 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2009-10-06 11:37 UTC (permalink / raw)
  To: gcc-bugs



-- 

sam at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 GCC target triplet|4.5.0                       |
   Target Milestone|---                         |4.5.0


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


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

* [Bug ada/37038] Bogus warning from GCC
  2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
                   ` (8 preceding siblings ...)
  2009-10-06 11:37 ` sam at gcc dot gnu dot org
@ 2009-10-06 11:37 ` sam at gcc dot gnu dot org
  9 siblings, 0 replies; 12+ messages in thread
From: sam at gcc dot gnu dot org @ 2009-10-06 11:37 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from sam at gcc dot gnu dot org  2009-10-06 11:37 -------
The issue is no longer present in trunk. Closing as fixed.


-- 

sam at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
 GCC target triplet|                            |4.5.0
         Resolution|                            |FIXED


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


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

end of thread, other threads:[~2009-10-06 11:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-06 14:49 [Bug ada/37038] New: Bogus warning from GCC sam at gcc dot gnu dot org
2008-08-06 14:50 ` [Bug ada/37038] " sam at gcc dot gnu dot org
2008-08-06 15:40 ` sam at gcc dot gnu dot org
2008-08-06 15:46   ` Andrew Thomas Pinski
2008-08-06 15:47 ` pinskia at gmail dot com
2008-08-06 16:58 ` sam at gcc dot gnu dot org
2008-08-10 20:18 ` pinskia at gcc dot gnu dot org
2008-08-10 20:32 ` sam at gcc dot gnu dot org
2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
2008-08-10 20:36 ` pinskia at gcc dot gnu dot org
2009-10-06 11:37 ` sam at gcc dot gnu dot org
2009-10-06 11:37 ` sam at gcc dot gnu dot 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).