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

            Bug ID: 122640
           Summary: Variable initialized with if expression not recognized
                    as constant
           Product: gcc
           Version: 15.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: ada
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jesper.quorning at gmail dot com
                CC: dkm at gcc dot gnu.org
  Target Milestone: ---

In the following small program the variable S is not recognized as a constant.

$ gnatmake -gnatwa program.adb

Expected warning that "S" could be declared as constant.

Thanks

```
procedure Program 
is
   function Run (F : Boolean) return String
   is
      S : String :=
        (if F
         then "foo"
         else "bar");
   begin
      return S;
   end Run;

   Unused : String := Run (False);
begin
   null;
end Program;
```

Reply via email to