HomeAbout Us A-Z IndexSearch * Contact Us Register LoginPress Shop

The Open Brand -- Problem Reporting and Interpretations System


Problem Report 0114 Details

Help Show help | Quick Search | Submit a Test Suite Support Request | Click here to view your privileges

This page provides all information on Problem Report 0114.


Report 0114 Actions


    Problem Report Number 0114
    Submitter's Classification Test Suite problem
    State Resolved
    Resolution Test Suite Deficiency (TSD)
    Problem Resolution ID TSD.X.0114
    Raised 1993-11-09 08:00
    Updated 2003-03-13 08:00
    Published 1993-11-19 08:00
    Product Standard Internationalised System Calls and Libraries (XPG4)
    Certification Program The Open Brand certification program
    Test Suite VSX4 version 4.2.4
    Test Identification XOPEN.os/genuts/tsearch
    Problem Summary TSD4.114 The tsearch.c test fails compilation on our implementation. The following example program better illustrates the problem: #include <stdio.h> typedef enum { RED, WHITE, BLUE } COLOR; int xyz(); int abc...
    Problem Text
    The tsearch.c test fails compilation on our implementation. The
    following example program better illustrates the problem:

    #include <stdio.h>

    typedef enum { RED, WHITE, BLUE } COLOR;

    int xyz();
    int abc(int (*)(COLOR));

    int main(void)
    {
    (void)printf("answer = %d\n", abc(xyz));
    return 0;
    }

    int xyz(c)
    COLOR c;
    {
    return c;
    }

    int abc(int (*f)(COLOR))
    {
    return (*f)(BLUE);
    }

    The program is passing the address of function xyz as an argument
    to function abc:

    (void)printf("answer = %d\n", abc(xyz));

    and the compiler complains:

    E "abcde.c",L10/C43(#416): xyz
    | Type `int()' can't be converted to type `int(*)(COLOR)'.
    1 user error No warnings

    When the function abc() is called with the xyz argument, a chain
    reaction of conditions must be satisfied:

    1. The type of the argument xyz must be assignable to an object
    with the unqualified version of the type of the first parameter
    of function abc. (ISO C, section 6.3.2.2, page 40, lines 20-23)
    Is the type of xyz, which is pointer to function returning int
    with no information about its parameters assignable to an object
    of type pointer to function returning int with one parameter of
    type COLOR?

    2. The assignment of pointer types is allowed only if the pointer
    types are compatible. (ISO C, section 6.3.16.1, page 53, lines
    24-25) Are these pointer types compatible?

    3. "For two pointer types to be compatible, both shall be identically
    qualified and both shall be pointers to compatible types." (ISO C,
    section 6.5.4.1, page 66, lines 24-25) In this case both pointer
    types are unqualified and point to function types. Are the
    referenced function types compatible?

    4. "For two function types to be compatible, both shall specify
    compatible return types ... If one type has a parameter type list
    and the other type is specified by a function declarator that is
    not part of a function definition and that contains an empty
    identifier list, the parameter list shall not have an ellipsis
    terminator, and the type of each parameter shall be compatible
    with the type that results from the application of the default
    argument promotions." (ISO C, section 6.5.4.3, page 68, lines
    12-18) Is the type of the parameter to function abc() compatible
    with the type that results from application of the default
    argument promotions?

    5. The default argument promotions applied to type COLOR (which
    is an enum) results in type int. (ISO C, section 6.3.2.2, page
    41, lines 1-3; section 6.2.1.1, page 34, lines 12-15) Is type
    COLOR compatible with type int?

    Our implementation chooses unsigned char as the underlying type for
    the enum which is represented by COLOR. Since unsigned char is not
    compatible with int (ISO C, section 6.1.2.6, page 25), type COLOR is
    not compatible with int, so xyz cannot be passed as an argument to
    function abc(), and the compiler issues the error. If our
    implementation chose int as the underlying enum type, then type COLOR
    would be compatible with int, and the compiler would not issue the
    error.

    However, ISO C (section 6.5.2.2, page 61, lines 40-41) states: "Each
    enumerated type shall be compatible with an integer type; the choice of
    type is implementation-defined." Since unsigned char is an integer
    type (ISO C, section 6.1.2.5, pages 22-23), our implementation is valid,
    and any application which assumes the underlying enum type is int is
    not portable. In addition, the X/Open C specification is no more
    restrictive than ISO C: "The properties of enum types are identical to
    those of some integer types. The implementation may use the range of
    values to determine how to allot storage." (XPG3 Programming Languages
    page 6)

    At this point, it should be clear that the underlying enum type is
    allowed to be unsigned char, the example program is not portable, and
    the compiler error is appropriate. Now consider the tsearch.c code.
    Our implementation declares twalk in <search.h> as required by XPG4:

    extern void twalk (const void *, void (*)(const void *, VISIT, int));

    The t13_action function is declared in tsearch.c as follows:

    private void t13_action();

    Based on the above declarations of twalk and t13_action, the compiler
    complains about the following line:

    twalk((void *)nrootp, t13_action);

    If you apply the conditions stated above, you will see that the
    compiler error is valid and the test case is not portable because
    type VISIT is not compatible with int on our implementation. For
    this reason, either a permanent waiver or permission to alter VSX4
    is requested.

    Here are the proposed changes to tset/XOPEN.os/genuts/tsearch/tsearch.c:

    1. Declare t13_action using a function prototype.

    #if TEST_ANSI
    private void t13_action(const void *, VISIT, int);
    #else
    private void t13_action();
    #endif

    2. Change the function definition to match the prototype. (The
    nodearg argument didn't match the prototype.)

    private void
    t13_action(nodearg, order, level)
    #if __STDC__
    const void *nodearg;
    #else
    char *nodearg; /* some old compilers don't grok (void *) args */
    #endif

    Here is the diff output of the original and modified files:

    129a130,132
    > #if TEST_ANSI
    > private void t13_action(const void *, VISIT, int);
    > #else
    130a134
    > #endif
    1224c1228
    < void *nodearg;
    ---
    > const void *nodearg;

    With these changes the tsearch.c test compiles and runs on our
    implementation without errors.
    Test Output
    /tset/XOPEN.os/genuts/tsearch/T.tsearch Failed

    Make Information:
    /tests/vsx4/vsx4/tools/cc_filter -I../../../../../inc/posix_c
    -I/tests/vsx4/vsx4/SRC/INC -I/tests/vsx4/vsx4/SRC/SYSINC
    -D_XOPEN_SOURCE -DUNDEFINEtsearch -DUNDEFINEtfind
    -DUNDEFINEtdelete -DUNDEFINEtwalk -w -c tsearch.c
    1 user error No warnings
    E "tsearch.c",L1155/C24(#416): t13_action
    | Type `void()' can't be converted to type `void(*)(const void
    *,VISIT,int)'.
    *** Error code 8

    Stop.

    Review Information

    Review Type TSMA Review
    Start Date null
    Completed null
    Status Complete
    Review Recommendation No Resolution Given
    Review Response
    This is agreed to be a test suite deficiency.

    Review Type SA Review
    Start Date null
    Completed null
    Status Complete
    Review Resolution Test Suite Deficiency (TSD)
    Review Conclusion
    This is an agreed Test Suite Deficiency.

    Problem Reporting System Options:

     

    Back   


Contact the Certification Authority