{"action":"opened","issue":{"url":"https://api.github.com/repos/nickg/nvc/issues/218","labels_url":"https://api.github.com/repos/nickg/nvc/issues/218/labels{/name}","comments_url":"https://api.github.com/repos/nickg/nvc/issues/218/comments","events_url":"https://api.github.com/repos/nickg/nvc/issues/218/events","html_url":"https://github.com/nickg/nvc/issues/218","id":99113011,"number":218,"title":"Stack dump: conversion function on complex data type","user":{"login":"rhinton","id":95578,"avatar_url":"https://avatars.githubusercontent.com/u/95578?v=3","gravatar_id":"","url":"https://api.github.com/users/rhinton","html_url":"https://github.com/rhinton","followers_url":"https://api.github.com/users/rhinton/followers","following_url":"https://api.github.com/users/rhinton/following{/other_user}","gists_url":"https://api.github.com/users/rhinton/gists{/gist_id}","starred_url":"https://api.github.com/users/rhinton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rhinton/subscriptions","organizations_url":"https://api.github.com/users/rhinton/orgs","repos_url":"https://api.github.com/users/rhinton/repos","events_url":"https://api.github.com/users/rhinton/events{/privacy}","received_events_url":"https://api.github.com/users/rhinton/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-05T04:22:08Z","updated_at":"2015-08-05T04:22:08Z","closed_at":null,"body":"I'm working on a conversion function for a fairly complex data type, and I get the following stack trace.\r\n\r\n```\r\nName       WORK.DNS_QUERY_LIST_PKG.TO_SLV$VuWORK.DNS_QUERY_LIST_PKG.QUERY_LIST_RECORD;\r\nKind       function\r\nContext    WORK.DNS_QUERY_LIST_PKG-body\r\nBlocks     1\r\nRegisters  95\r\nTypes      27\r\n  WORK.DNS_QUERY_LIST_PKG.QUERY_LIST_RECORD {0..8, [32] : 0..8, [16] : 0..8, [16] : 0..8, [64] : 0..8, [13] : 0..8, [13] : 0..8, [64] : 0..8, [128] : 0..8, [*] : 0..8, 0..8}\r\nVariables  1\r\n  RESULT                                // [*] : 0..8 \r\nResult     [*] : 0..8\r\nParameters 1\r\n  r0    QL_REC                          // @<WORK.DNS_QUERY_LIST_PKG.QUERY_LIST_RECORD{}> \r\nBegin\r\n   0: r1 := const 0                     // -2^31..2^31-1 => 0 \r\n      r2 := const 347                   // -2^31..2^31-1 => 347 \r\n      r3 := const 4                     // -2^31..2^31-1 => 4 \r\n      // Elided bounds check for r3 \r\n      r4 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r5 := add r2 + r4                 // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r6 := const 1                     // -2^31..2^31-1 => 1 \r\n      r7 := add r5 + r6                 // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r8 := sub r7 - r6                 // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r9 := add r8 + r6                 // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r10 := cast r9                    // # => -2147483300..2147483995 \r\n      r11 := const 0                    // # => 0 \r\n      r12 := cmp r10 < r11\r\n      r13 := select r12 then r11 else r10 // # \r\n      r14 := alloca r13                 // @<0..8> => 0..8 \r\n      // Elided bounds check for r3 \r\n      r15 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r16 := add r2 + r15               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r17 := add r16 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r18 := sub r17 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r19 := const 0                    // 0..1 => 0 \r\n      r20 := wrap r14 [r1 r18 r19]      // [*] : 0..8 \r\n      RESULT := store r20\r\n      storage hint r14 length r13       // 0..8 \r\n      // Begin dynamic aggregrate line 95 \r\n      r21 := const 0                    // 0..8 => 0 \r\n      // Elided bounds check for r3 \r\n      r22 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r23 := add r2 + r22               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r24 := add r23 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r25 := sub r24 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      // Elided bounds check for r3 \r\n      r26 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r27 := add r2 + r26               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r28 := add r27 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r29 := sub r28 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r30 := add r29 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r31 := cast r30                   // # => -2147483300..2147483995 \r\n      r32 := cmp r31 < r11\r\n      r33 := select r32 then r11 else r31 // # \r\n      r34 := alloca r33                 // @<0..8> => 0..8 \r\n      r34 := memset r21 length r33\r\n      r35 := wrap r34 [r1 r25 r19]      // [*] : 0..8 \r\n      // Elided bounds check for r3 \r\n      r36 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r37 := add r2 + r36               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r38 := add r37 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r39 := sub r38 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      index check low r1 high r39 in 0..2^31-1 subkind 6\r\n      // Elided bounds check for r3 \r\n      r40 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r41 := add r2 + r40               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r42 := add r41 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r43 := sub r42 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r44 := add r43 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r45 := cast r44                   // # => -2147483300..2147483995 \r\n      r46 := cmp r45 < r11\r\n      r47 := select r46 then r11 else r45 // # \r\n      // Elided bounds check for r3 \r\n      r48 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r49 := add r2 + r48               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r50 := add r49 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r51 := sub r50 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r52 := add r51 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r53 := cast r52                   // # => -2147483300..2147483995 \r\n      r54 := cmp r53 < r11\r\n      r55 := select r54 then r11 else r53 // # \r\n      array size left r47 == right r55\r\n      r14 := copy r34 count r13\r\n      r56 := heap save                  // # \r\n      // Elided bounds check for r3 \r\n      r57 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r58 := add r2 + r57               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r59 := add r58 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r60 := sub r59 - r6               // -2^31..2^31-1 => -2147483301..2147483994 \r\n      r61 := add r60 + r6               // -2^31..2^31-1 => -2147483300..2147483995 \r\n      r62 := cast r61                   // # => -2147483300..2147483995 \r\n      r63 := cmp r62 < r11\r\n      r64 := select r63 then r11 else r62 // # \r\n      storage hint r14 length r64       // 0..8 \r\n      r65 := record ref r0 field 0      // @<0..8> => 0..8 \r\n      r66 := record ref r0 field 1      // @<0..8> => 0..8 \r\n      r67 := const 3                    // -2^31..2^31-1 => 3 \r\n      r68 := wrap r66 [r1 r67 r19]      // [*] : 0..8 \r\n      r69 := fcall WORK.BYTE_TYPES_PKG.TO_SLV$VuWORK.BYTE_TYPES_PKG.BYTE_VECTOR; r68 // [*] : 0..8 \r\n      r70 := record ref r0 field 2      // @<0..8> => 0..8 \r\n      r71 := const 15                   // -2^31..2^31-1 => 15 \r\n      r72 := const 1                    // 0..1 => 1 \r\n      r73 := wrap r70 [r71 r1 r72]      // [*] : 0..8 \r\n      r74 := record ref r0 field 3      // @<0..8> => 0..8 \r\n      r75 := wrap r74 [r71 r1 r72]      // [*] : 0..8 \r\n      r76 := record ref r0 field 4      // @<0..8> => 0..8 \r\n      r77 := const 63                   // -2^31..2^31-1 => 63 \r\n      r78 := wrap r76 [r77 r1 r72]      // [*] : 0..8 \r\n      r79 := record ref r0 field 5      // @<0..8> => 0..8 \r\n      r80 := const 5                    // -2^31..2^31-1 => 5 \r\n      r81 := const -7                   // -2^31..2^31-1 => -7 \r\n      r82 := wrap r79 [r80 r81 r72]     // [*] : 0..8 \r\n      r83 := fcall WORK.FIXED_PKG_C.TO_SLV$VuWORK.FIXED_PKG_C.UNRESOLVED_UFIXED; r82 // [*] : 0..8 \r\n      r84 := record ref r0 field 6      // @<0..8> => 0..8 \r\n      r85 := wrap r84 [r80 r81 r72]     // [*] : 0..8 \r\n      r86 := fcall WORK.FIXED_PKG_C.TO_SLV$VuWORK.FIXED_PKG_C.UNRESOLVED_UFIXED; r85 // [*] : 0..8 \r\n      r87 := record ref r0 field 7      // @<0..8> => 0..8 \r\n      r88 := wrap r87 [r77 r1 r72]      // [*] : 0..8 \r\n      r89 := record ref r0 field 8      // @<0..8> => 0..8 \r\n      r90 := wrap r89 [r1 r67 r19]      // [*] : 0..8 \r\n      r91 := fcall WORK.IP_NETWORK_PKG.TO_SLV$VuWORK.IP_NETWORK_PKG.IP4_ADDRESS_VECTOR; r90 // [*] : 0..8 \r\n      r92 := record ref r0 field 9      // @<[*] : 0..8> => [*] : 0..8 \r\n      // Elided bounds check for r3 \r\n      r93 := fcall WORK.MATH_MVD.CEILLOG2$II r3 // -2^31..2^31-1 \r\n      r94 := sub r93 - r6               // -2^31..2^31-1 => -2147483649..2147483646 \r\n      invalid := wrap r92 [r94 r1 r72]\r\n\r\n** Fatal: array types may not be nested\r\n\r\n-------- STACK TRACE --------\r\nnvc() [0x409f9e]\r\nnvc() [0x40b42d]\r\nnvc() [0x45fb2a]\r\nnvc() [0x4626ac]\r\nnvc() [0x453887]\r\nnvc() [0x451c1b]\r\nnvc() [0x455ff1]\r\nnvc() [0x451c03]\r\nnvc() [0x4587f0]\r\nnvc() [0x4598d9]\r\nnvc() [0x45a276]\r\nnvc() [0x40797e]\r\nnvc() [0x407fd4]\r\n/lib64/libc.so.6(__libc_start_main+0xfd) [0x3b2521ed5d]\r\nnvc() [0x4065a9]\r\n-----------------------------\r\n```\r\n\r\nI'm happy to provide source code, but I would rather not post it publicly.  Here is the data type and local code it's working with (but much more code is needed for a complete test case):\r\n\r\n```vhdl\r\n  -- conversion functions\r\n  function to_slv (ql_rec : query_list_record) return std_logic_vector is\r\n    variable result : std_logic_vector(0 to LEN_QLREC-1);\r\n  begin\r\n    result := ql_rec.valid &\r\n              to_slv(ql_rec.origin_ip) &\r\n              std_logic_vector(ql_rec.origin_port) &\r\n              std_logic_vector(ql_rec.dns_pkt_id) &\r\n              std_logic_vector(ql_rec.name_key) &\r\n              to_slv(ql_rec.time_created) &\r\n              to_slv(ql_rec.last_activity) & \r\n              std_logic_vector(ql_rec.ns_name_key) &\r\n              to_slv(ql_rec.ns_host_ips) &\r\n              std_logic_vector(ql_rec.ns_host_next_ip) &\r\n              ql_rec.ns_has_unresolved_hosts;\r\n    return result;\r\n  end function to_slv;\r\n```\r\n\r\nand the data type:\r\n\r\n```vhdl\r\n  type query_list_record is record\r\n    valid                   : std_logic;  -- high if this record is valid\r\n    origin_ip               : ip4_address;     -- request source IP address\r\n    origin_port             : ip_port;  -- request source IP port\r\n    dns_pkt_id              : uint16;   -- request DNS packet ID\r\n    name_info                : dns_name_info; --std_logic_vector\r\n    time_created            : ufixed(6-1 downto -7);  -- absolute time created in seconds\r\n    last_activity           : ufixed(6-1 downto -7);  -- absolute last activity in seconds\r\n    ns_name_info             : dns_name_info;  --std_logic_vector\r\n    ns_host_ips             : ip4_address_vector(0 to LEN_HOST_IPS-1);  -- known IP addresses for current NS\r\n    ns_host_next_ip         : unsigned(WI_HOST_IP_IDX-1 downto 0);  -- next NS IP to consult\r\n    ns_has_unresolved_hosts : std_logic;  -- high when NS has unresolved hosts\r\n  end record query_list_record;\r\n```\r\n\r\nLet me know the best way to proceed.\r\n"}}