public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug ada/35464]  New: "warning: condition is always False" not issued inside generics
@ 2008-03-04 21:15 ludovic at ludovic-brenta dot org
  2008-03-05  8:35 ` [Bug ada/35464] " sam at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ludovic at ludovic-brenta dot org @ 2008-03-04 21:15 UTC (permalink / raw)
  To: gcc-bugs

With -gnatwa, GNAT emits very useful warnings; one of them is "condition is
always False".  However, GNAT does not emit this warning when it applies inside
a generic, or a generic instantiation.  The following test case demonstrates
the problem.

procedure Condition_Is_Always_False is

   type T is range 3 .. 4;

   function F return T is
   begin
      return T'First;
   end F;

   procedure OK is
      C : constant T := F;
   begin
      if C = 1 then -- warning: condition is always False
         null;
      end if;
   end OK;

   generic
   procedure NOK_G;

   procedure NOK_G is
      C : constant T := F; -- T'First instead of F gives the warning
   begin
      if C = 1 then -- no warning
         null;
      end if;
   end NOK_G;

   procedure NOK is new NOK_G;

begin -- Condition_Is_Always_False
   OK;
   NOK;
end  Condition_Is_Always_False;

gcc-4.1 -c -gnatwa condition_is_always_false.adb
condition_is_always_false.adb:13:12: warning: condition is always False
gnatbind -x condition_is_always_false.ali
gnatlink condition_is_always_false.ali

If, however, C is initialized directly with T'First (a static value) instead of
the result of F (a static function), GNAT gives the warning even inside the
generic.


-- 
           Summary: "warning: condition is always False" not issued inside
                    generics
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: ada
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ludovic at ludovic-brenta dot org


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


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

end of thread, other threads:[~2008-05-12 22:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-04 21:15 [Bug ada/35464] New: "warning: condition is always False" not issued inside generics ludovic at ludovic-brenta dot org
2008-03-05  8:35 ` [Bug ada/35464] " sam at gcc dot gnu dot org
2008-03-05  8:38 ` sam at gcc dot gnu dot org
2008-05-12 22:39 ` charlet 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).