Menu ▾ ▴

#4141 bug-4139 fails for multiple targets

open
nobody
None
other
5
16 hours ago
1 day ago
No

regression test bug-4139 fails for hc08, mcs51-large and mcs51-huge.

Related

Bugs: #4139

Discussion

  • Christopher Bazley

    I'm sorry about the regression.

    I believe the cause is shared parameter metadata: an inferred function-pointer type shares the original function’s parameter symbols. Processing the new declaration renames those shared symbols. Copying the parameter list for the inferred type prevents that.

    I'll attach a patch as soon as I can.

     
  • Christopher Bazley

    The missing symbol is _next_value_10000_9. The original parameter's storage metadata has been changed while processing the inferred pointer declaration, leaving its generated code referring to unallocated storage. The inferred type and original function share FUNC_ARGS: copyLinkChain copies the function link, but not its parameter values or symbols.

    The candidate fix for this regression copies each function declarator's parameter chain in the inferred type. It leaves the original function's symbols intact. There is no need to weaken the existing regression test or make its function reentrant merely to avoid the failure.

    All new test cases are in regression. They are valid programs; the required observations are successful linking and correct call results. There are no diagnostic expectations that would justify a valdiag file.

    bug-4139.c: reproduces all three reported link failures. After the fix, all 18 assertions pass on each reported target.

    bug-4141.c: function conversion, explicit address, copying an inferred pointer, another source function, and direct calls after inference. These tests exercise independent parameter metadata and actual argument passing. A reentrant two-argument function checks parameter order and
    values where indirect calls require reentrancy. The call count checks that all expected calls happened. Before the fix this test fails to link on all three reported targets; after it all 12 assertions pass on each.

    The new test uses a counter in its callees so HC08 cannot keep every parameter entirely in registers and thereby hide the storage defect.

    101 files in valdiag have unchanged results on each of HC08, MCS51 large/stack-auto, STM8 and Z80.

    Please consider the attached candidate bug fix.

     
  • Maarten Brock

    Maarten Brock - 16 hours ago

    I intend to apply this patch.

    But I also noticed that the regression tests bug-4139.c, bug-4140.c & bug-4141.c all fail for host with GCC v11.4. Is there a macro that can be checked for these tests?

    Running host regression tests
    In file included from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c: In function ‘testInferenceConversions’:
    cases/./../tests/bug-4139.c:37:10: error: subscripted value is neither array nor pointer nor vector
       37 |   pointer[1] = 7;
          |          ^
    In file included from cases/./../tests/bug-4139.c:2,
                     from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:43:10: error: invalid type argument of unary ‘*’ (have ‘int’)
       43 |   ASSERT(*cursor == 7);
          |          ^~~~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:47:6: error: subscripted value is neither array nor pointer nor vector
       47 |   row[1][0] = 9;
          |      ^
    In file included from cases/./../tests/bug-4139.c:2,
                     from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:52:10: error: invalid type argument of unary ‘*’ (have ‘int’)
       52 |   ASSERT(*text == 'b');
          |          ^~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    cases/./../tests/bug-4139.c:56:10: error: called object ‘function’ is not a function or function pointer
       56 |   ASSERT(function(4) == 5);
          |          ^~~~~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:55:8: note: declared here
       55 |   auto function = next;
          |        ^~~~~~~~
    In file included from cases/./../tests/bug-4139.c:2,
                     from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:64:10: error: called object ‘address’ is not a function or function pointer
       64 |   ASSERT(address(6) == 7);
          |          ^~~~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:63:8: note: declared here
       63 |   auto address = &next;
          |        ^~~~~~~
    cases/./../tests/bug-4139.c:72:25: error: incompatible types when initializing type ‘int’ using type ‘struct S’
       72 |   auto aggregate_copy = aggregate;
          |                         ^~~~~~~~~
    cases/./../tests/bug-4139.c:73:17: error: request for member ‘member’ in something not a structure or union
       73 |   aggregate_copy.member = 2;
          |                 ^
    In file included from cases/./../tests/bug-4139.c:2,
                     from cases/tst_bug-4139.c:1:
    cases/./../tests/bug-4139.c:74:24: error: request for member ‘member’ in something not a structure or union
       74 |   ASSERT(aggregate_copy.member == 2);
          |                        ^
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    make[3]: *** [Makefile:434: gen/host/tst_bug-4139.o] Fout 1
    results/host/tst_bug-4139.out:2:--- FAIL: cannot compile/link cases/tst_bug-4139.c
    Failure: cases/tst_bug-4139.c
    tst_bug-4139                        (f:  1, t:   1, c:    1, b:       0, T:         0)
    In file included from cases/tst_bug-4140.c:1:
    cases/./../tests/bug-4140.c: In function ‘testExplicitAutoTypes’:
    cases/./../tests/bug-4140.c:84:3: error: static assertion failed: "unsigned char object"
       84 |   _Static_assert(_Generic(&inferred_small, unsigned char *: 1, default: 0), "unsigned char object");
          |   ^~~~~~~~~~~~~~
    cases/./../tests/bug-4140.c:85:3: error: static assertion failed: "float object"
       85 |   _Static_assert(_Generic(&inferred_float, float *: 1, default: 0), "float object");
          |   ^~~~~~~~~~~~~~
    make[3]: *** [Makefile:434: gen/host/tst_bug-4140.o] Fout 1
    results/host/tst_bug-4140.out:2:--- FAIL: cannot compile/link cases/tst_bug-4140.c
    Failure: cases/tst_bug-4140.c
    tst_bug-4140                        (f:  1, t:   1, c:    1, b:       0, T:         0)
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c: In function ‘testInferredFunctionParameters’:
    cases/./../tests/bug-4141.c:47:10: error: called object ‘first’ is not a function or function pointer
       47 |   ASSERT(first(4) == 5);
          |          ^~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:45:8: note: declared here
       45 |   auto first = increment;
          |        ^~~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:48:10: error: called object ‘second’ is not a function or function pointer
       48 |   ASSERT(second(6) == 7);
          |          ^~~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:46:8: note: declared here
       46 |   auto second = &increment;
          |        ^~~~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:53:10: error: called object ‘third’ is not a function or function pointer
       53 |   ASSERT(third(8) == 9);
          |          ^~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:51:8: note: declared here
       51 |   auto third = first;
          |        ^~~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:54:10: error: called object ‘other’ is not a function or function pointer
       54 |   ASSERT(other(10) == 9);
          |          ^~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:52:8: note: declared here
       52 |   auto other = decrement;
          |        ^~~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:55:10: error: called object ‘first’ is not a function or function pointer
       55 |   ASSERT(first(12) == 13);
          |          ^~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:45:8: note: declared here
       45 |   auto first = increment;
          |        ^~~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:56:10: error: called object ‘second’ is not a function or function pointer
       56 |   ASSERT(second(14) == 15);
          |          ^~~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:46:8: note: declared here
       46 |   auto second = &increment;
          |        ^~~~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:65:10: error: called object ‘pair’ is not a function or function pointer
       65 |   ASSERT(pair(2, 3) == 23);
          |          ^~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:63:8: note: declared here
       63 |   auto pair = combine;
          |        ^~~~
    In file included from cases/./../tests/bug-4141.c:2,
                     from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:66:10: error: called object ‘pair_address’ is not a function or function pointer
       66 |   ASSERT(pair_address(4, 5) == 45);
          |          ^~~~~~~~~~~~
    ./fwk/include/testfwk.h:140:37: note: in definition of macro ‘ASSERT’
      140 | #define ASSERT(_a)  (++__numTests, (_a) ? (void)0 : __fail ("Assertion failed", #_a, __FILE__, __LINE__))
          |                                     ^~
    In file included from cases/tst_bug-4141.c:1:
    cases/./../tests/bug-4141.c:64:8: note: declared here
       64 |   auto pair_address = &combine;
          |        ^~~~~~~~~~~~
    make[3]: *** [Makefile:434: gen/host/tst_bug-4141.o] Fout 1
    results/host/tst_bug-4141.out:2:--- FAIL: cannot compile/link cases/tst_bug-4141.c
    Failure: cases/tst_bug-4141.c
    tst_bug-4141                        (f:  1, t:   1, c:    1, b:       0, T:         0)
    Summary for 'host'                   :      3 failures, 31769 tests, 6414 test cases,        0 bytes,          0 ticks
       Failure: cases/tst_bug-4139.c
       Failure: cases/tst_bug-4140.c
       Failure: cases/tst_bug-4141.c
    
     

Log in to post a comment.