Labeled exit within generalized labeled loop not allowed?



I find it hard to believe that this would be a GNAT GPL 2012 compiler bug, but I don't see anything in the LRM that indicates this wouldn't be legal.

Code containing a labeled generalized loop (the "for Elem of Some_Container" type), with a conditional exit referencing the loop label, fails to compile with an "Invalid loop name in exit statement" error.

What's the rationale for this? Or a consequence of what? Or is it a compiler bug?

Marc A. Criley

Here's an example:

with Text_IO; use Text_IO;

procedure Loop_Check is

type Int_Array_Type is array (1..10) of Integer;

IA : Int_Array_Type := (6 => 6, others => 3);

begin
Loop_A: For I in IA'range loop
Put_Line(Integer'Image(IA(I)));
exit Loop_A When IA(I) = 6;
end loop Loop_A;

Loop_B: For I of IA loop
Put_Line(Integer'Image(I));
exit when I = 6;
end loop Loop_B;

Loop_C: For I of IA loop
Put_Line(Integer'Image(I));
exit Loop_C when I = 6; -- Compiler error on this line
end loop Loop_C;
end Loop_Check;
.



Relevant Pages

  • Re: NAG, Sun, Compaq possible f95 bug
    ... Richard Maine wrote: ... >> out of a DO loop that would normally set the DO variable. ... The standard doesn't distinguish ... If it doesn't have that value, then it is a compiler bug, ...
    (comp.lang.fortran)
  • Re: NAG, Sun, Compaq possible f95 bug
    ... > out of a DO loop that would normally set the DO variable. ... The standard doesn't distinguish ... If it doesn't have that value, then it is a compiler bug, ... tell the difference - for example, if you never reference the value. ...
    (comp.lang.fortran)
  • Re: Compiler Optimization Question - Flashing code doesnt work wh
    ... It's not a compiler bug for which there would be a fix. ... > of loop or removal of loops? ... >>> smaillet at EmbeddedFusion dot com ...
    (microsoft.public.windowsce.platbuilder)
  • Re: C++ style questions (OOP)
    ... > neo88 wrote: ... > The code I supplied doesn't fit inside the while loop. ... Either there's a compiler bug, ... Read them, then fix it. ...
    (comp.lang.cpp)
  • Re: A different kind of adaptor iterator
    ... source of my problem - a compiler bug. ... With g++-3.2.2 the function object is only invoked ONCE! ... g++-3.3.2 it is invoked on every iteration of the loop (as ...
    (comp.lang.cpp)