# Can someone test this short code (compiler error?)

**URL:** https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121
**Category:** General
**Created:** [January 16, 2026, 5:24pm UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121 "2026-01-16T17:24:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![reinert](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@reinert](https://forum.ada-lang.io/u/reinert)
#### Post date: [January 16, 2026, 5:24pm UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/1 "2026-01-16T17:24:48Z")

</div>

Could someone test this code:

```ada
with Ada.Text_IO; use Ada.Text_IO;
procedure test1 is

  type fam_rel1_t is (f_c, f_d1, f_d2, f_d3, f_d4, f_d5, f_d6);
  for fam_rel1_t use (f_c=>1, f_d1=>2, f_d2=>3, f_d3=>4, f_d4=>5, f_d5=>6, f_d6=>7);

begin

   for d in fam_rel1_t loop
       if d /= f_c then
          put_line("Here 1: " & d'Image);
       end if;
   end loop;

   Put_Line("============================");

   for d in fam_rel1_t when d /= f_c loop
       put_line("Here 2: " & d'Image);
   end loop;

end test1;

```

I get this output when I include “for .. use”:  
Here 1: F\_D1  
Here 1: F\_D2  
Here 1: F\_D3  
Here 1: F\_D4  
Here 1: F\_D5  
Here 1: F\_D6

=====================================

Here 2: F\_C  
Here 2: F\_D1  
Here 2: F\_D2  
Here 2: F\_D3  
Here 2: F\_D4  
Here 2: F\_D5  
Here 2: F\_D6

I use latest version of debian and alire.

---

<div class="post-metadata">

### Author: ![pmnw](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pmnw](https://forum.ada-lang.io/u/pmnw)
#### Post date: [January 16, 2026, 6:11pm UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/2 "2026-01-16T18:11:29Z")

</div>

Here you go: [Compiler Explorer](https://godbolt.org/z/b3sjeY1r3)  
(I changed the procedure name to `example` because of some Godbolt peculiarities)

Edit:  
a sounder example: [Compiler Explorer](https://godbolt.org/z/5v5q4PvqP)

---

<div class="post-metadata">

### Author: ![Irvise](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/i/7ba0ec/32.png) [@Irvise](https://forum.ada-lang.io/u/Irvise)
#### Post date: [January 16, 2026, 7:26pm UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/3 "2026-01-16T19:26:54Z")

</div>

I changed the compiler to truck and it does the same! Wierd! Mmmmm… This looks like a compiler bug… I think this should be reported to upstream.

---

<div class="post-metadata">

### Author: ![charlie5](https://forum.ada-lang.io/user_avatar/forum.ada-lang.io/charlie5/32/626_2.png) [@charlie5](https://forum.ada-lang.io/u/charlie5)
#### Post date: [January 17, 2026, 4:23am UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/4 "2026-01-17T04:23:47Z")

</div>

Same result on Arch gcc version 15.2.1 20260103.

I’ve never seen a ‘when’ in a ‘for’ loop like that before. Is it a new 2022 addition ?

---

<div class="post-metadata">

### Author: ![reinert](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/r/46a35a/32.png) [@reinert](https://forum.ada-lang.io/u/reinert)
#### Post date: [January 17, 2026, 6:42am UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/5 "2026-01-17T06:42:02Z")

</div>

I made an illegal construct (without getting an error message) ?

Note that “for .. use” has an effect. Try to comment it out (or remove it).

---

<div class="post-metadata">

### Author: ![Irvise](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/i/7ba0ec/32.png) [@Irvise](https://forum.ada-lang.io/u/Irvise)
#### Post date: [January 17, 2026, 8:48am UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/6 "2026-01-17T08:48:59Z")

</div>

> [@charlie5](#):
>
> I’ve never seen a ‘when’ in a ‘for’ loop like that before. Is it a new 2022 addition ?

Yup! It is new syntax 🙂

> [@reinert](#):
>
> Note that “for .. use” has an effect. Try to comment it out (or remove it).

Afaik, it is only a representation clause, so it should not affect the logic…

---

<div class="post-metadata">

### Author: ![pmnw](https://forum.ada-lang.io/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@pmnw](https://forum.ada-lang.io/u/pmnw)
#### Post date: [January 17, 2026, 9:24am UTC](https://forum.ada-lang.io/t/can-someone-test-this-short-code-compiler-error/4121/7 "2026-01-17T09:24:58Z")

</div>

Has already been reported some time ago:

> **[121316 – representation clause on enumeration type causes iterator filters to...](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121316)**
