diff --git a/.gitattributes b/.gitattributes
index 3973a35c2e..5755696dd0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -18649,6 +18649,7 @@ tests/webtbs/tw38385.pp svneol=native#text/pascal
 tests/webtbs/tw38390.pp svneol=native#text/pascal
 tests/webtbs/tw3840.pp svneol=native#text/plain
 tests/webtbs/tw3841.pp svneol=native#text/plain
+tests/webtbs/tw38412.pp svneol=native#text/pascal
 tests/webtbs/tw38413.pp svneol=native#text/pascal
 tests/webtbs/tw3863.pp svneol=native#text/plain
 tests/webtbs/tw3864.pp svneol=native#text/plain
diff --git a/compiler/ncon.pas b/compiler/ncon.pas
index dabb8fac44..048624d664 100644
--- a/compiler/ncon.pas
+++ b/compiler/ncon.pas
@@ -655,7 +655,7 @@ implementation
         resultdef:=typedef;
         { only do range checking when explicitly asked for it
           and if the type can be range checked, see tests/tbs/tb0539.pp }
-        if (resultdef.typ in [orddef,enumdef]) then
+        if (resultdef.typ in [orddef,enumdef]) and not(nf_generic_para in flags) then
           adaptrange(resultdef,value,nf_internal in flags,not rangecheck,rangecheck)
       end;
 
diff --git a/tests/webtbs/tw38412.pp b/tests/webtbs/tw38412.pp
new file mode 100644
index 0000000000..dcfe911a99
--- /dev/null
+++ b/tests/webtbs/tw38412.pp
@@ -0,0 +1,10 @@
+{ %norun }
+type
+    measure = (short := 1, long := 2);
+    generic bar<const x: measure> = object
+            public
+                const
+                    myMeasure = ord(x);
+        end;
+begin
+end.