https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116644
Bug ID: 116644
Summary: Warnings in generic code don't report column number
Product: gcc
Version: 14.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: ada
Assignee: unassigned at gcc dot gnu.org
Reporter: mytbk920423 at gmail dot com
CC: dkm at gcc dot gnu.org
Target Milestone: ---
When compiling the following Ada code, GCC gives a warning with the correct
line number, but doesn't have the column number in it, which is insufficient
for me to find the bug in the code.
code:
-- gen_testpkg.ads
generic
type T is mod <>;
package Gen_Testpkg is
function Test_Mod(A : T) return T;
end Gen_Testpkg;
-- gen_testpkg.adb
package body Gen_Testpkg is
function Test_Mod(A : T) return T is
type U8 is mod 256;
Map : constant array (U8) of U8 :=
(1, 3, 5, others => 0);
begin
return T(Map(U8(A mod 256)));
-- ^^^
-- If T'Modulus <= 256, then 256 is not in range of type T
-- We can use U8'Mod(A) instead
end Test_Mod;
end Gen_Testpkg;
-- test_generic.adb
with Gen_Testpkg;
procedure Test_Generic is
type My_Byte is mod 256;
package My_Pkg is new Gen_Testpkg(T => My_Byte);
begin
null;
end Test_Generic;
warning:
test_generic.adb:6:03: warning: in instantiation at gen_testpkg.adb:8 [enabled
by default]
test_generic.adb:6:03: warning: value not in range of type "My_Byte" defined at
line 5 [enabled by default]
test_generic.adb:6:03: warning: Constraint_Error will be raised at run time
[enabled by default]