Bug 115507 - bogus Constraint_Error for Wide_Wide_Value with wide enumeration literal
Summary: bogus Constraint_Error for Wide_Wide_Value with wide enumeration literal
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: ada (show other bugs)
Version: 15.0
: P3 normal
Target Milestone: ---
Assignee: Eric Botcazou
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-16 00:57 UTC by Xin Wang
Modified: 2024-06-19 07:28 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2024-06-18 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Xin Wang 2024-06-16 00:57:01 UTC
For following code, CONSTRAINT_ERROR exception will be raised:

```
with Ada.Wide_Wide_Text_IO ;

procedure Sample is
   use Ada.Wide_Wide_Text_IO ;

   type T is (A, 乙) ;
begin
   Put_Line (A'Wide_Wide_Image) ;
   Put_Line (乙'Wide_Wide_Image) ;

   Put_Line (T (T'Wide_Wide_Value ("A"))'Wide_Wide_Image) ;
   Put_Line (T (T'Wide_Wide_Value ("乙"))'Wide_Wide_Image) ;
end Sample ;
```

Output:

```
A
乙                                                                                                                      A

raised CONSTRAINT_ERROR : bad input for 'Value: "乙"
[./sample]
0x41cd20 System.Val_Util.Bad_Value at s-valuti.adb:61
0x41c6d9 System.Val_Enum_8.Impl.Value_Enumeration at s-valuen.adb:149
0x404a4d Sample at sample.adb:12
0x4046b7 Main at b~sample.adb:258
[/lib/x86_64-linux-gnu/libc.so.6]
0x7fc03814f248
0x7fc03814f303
[./sample]
0x4040ef _start at ???
0xfffffffffffffffe
```

'Wide_Value will also failed with the same error.

I've tested in Debian 12 x86_64 with GNAT 15.0.0 20240615 (git 079506).
Comment 1 Eric Botcazou 2024-06-18 22:13:29 UTC
System.Val_Util.Normalize_String incorrectly normalizes the input string.
Comment 2 Eric Botcazou 2024-06-19 07:28:36 UTC
I'll have a closer look.