2017-03-15 2 views
2

최근 GCC 버전 (4.8.2 - 5.3.0)을 업데이트하고 일부 Ada 응용 프로그램에서 예상치 못한 제약 조건 오류가 발생하기 시작했습니다. 나는 다음에 감소했습니다GCC 업데이트 후 예기치 않은 CONSTRAINT_ERROR

-- moo.adb 
with text_io; 
procedure moo is 
    type thing_type is (something1,something2,something3,something4,something5,something6); 
    for thing_type use (something1 => 1,something2 => 2,something3 => 
     3,something4 => 4,something5 => 5,something6 => 6); 
    for thing_type'size use 32; 
    type thing_array_t is array (0 .. 5) of thing_type; 
    thing_array : thing_array_t := (others => something1); 
begin 
    text_io.put_line("item 0 = " & thing_type'image(thing_array(0))); 
end moo; 

이 프로그램은 4.8.2로 구축 할 때, 출력이 예상대로 (. 단순히 "gnatmake moo.adb"컴파일) GCC 버전 중 하나에 잘 컴파일 : 5.0.3 빌드 할 때

item 0 = SOMETHING1 

, 우리는 대신 32 비트 및 64 비트 컴파일 할 때

raised CONSTRAINT_ERROR : moo.adb:13 invalid data 

는 흥미롭게도, 결과는 정확히 동일받을 수 있습니다. thing_type'size 절을 제거하거나, 열거 자에 값을 추가하거나 제거하거나, 배열의 항목 수를 변경하거나, 배열을 초기화하는 데 다른 값을 사용하는 등 많은 것들이 변경 될 수 있습니다. 이 문제를 설명 할 수있는이 코드에 명백한 문제가 있습니까?

+0

입니까? (귀하의 목록에만 12 행만 있습니다.) –

+0

죄송합니다. 붙여 넣을 때 원본에서 빈 줄을 제거했습니다. 13 행은 text_io 행입니다. – Kevin

답변

6

이 버그는 여전히 GCC 7.0.1에 있습니다. 디버거에서 실행 출력 약간

(gdb) catch exception 
Catchpoint 2: all Ada exceptions 
(gdb) run 
Starting program: /Users/simon/tmp/so/moo 
[New Thread 0x1703 of process 75511] 

Catchpoint 2, CONSTRAINT_ERROR (moo.adb:10 invalid data) at 0x0000000100001abe in _ada_moo() at moo.adb:10 
10  text_io.put_line("item 0 = " & thing_type'image(thing_array(0))); 
(gdb) p thing_array 
$5 = (0 => 16843009, 16843009, 16843009, 16843009, 16843009, 16843009) 
(gdb) p/x thing_array 
$6 = (0 => 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101, 0x1010101) 

너무 GNAT 실수 오히려 모든 소자 대신에 16#01#thing_array 각 요소의 바이트를 설정하고, 편집.

something1이 2로 설정되고 (마찬가지로 나중에 값이 증가하는 경우) 동일하게 발생합니다. 나는이 도움이 찾을 수 있습니다

있는 유일한 방법은 라인 (13)에 게다가, 예를 들어, 선언

type base_thing_type is (invalid, something1,something2,something3,something4,something5,something6); 
for base_thing_type use (invalid => 0, something1 => 1,something2 => 2,something3 => 
         3,something4 => 4,something5 => 5,something6 => 6); 
for base_thing_type'size use 32; 
type thing_type is new base_thing_type range something1 .. something6; 
+0

시몬, GCC에 버그 보고서를 제출해 주겠다. – Kevin

+0

케빈,이 버그를보고 한 적이 있니? 여전히 GCC 8.0.0에있다. 20171216 –

4

GCC/GNAT의 버그처럼 보입니다. 표준 호환 모드 (-gnato -fstack-check -gnat12)로 GNAT-GPL-2016의 잘못된 동작을 복제 할 수 있습니다. 중요한 부분은 Something1이 더 일반적인 0 대신에 1으로 표시되는 것 같습니다. 버그를 GCC 개발자에게보고하는 것이 좋습니다.

+0

고마워, 버그보고 : – Kevin