bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo-4.2: some comments, and two failures


From: Nelson H. F. Beebe
Subject: texinfo-4.2: some comments, and two failures
Date: Sat, 6 Apr 2002 11:03:43 -0700 (MST)

[I'm cc'ing this to address@hidden, because the problem on
Apple Darwin would not be there except for a recent change in GNU
grep.]

I did builds of texinfo-4.2 on 18 different UNIX platforms; almost all
passed the validation tests flawlessly.

However, there were a few problems:

------------------------------------------------------------------------
(1) On Apple Darwin (== MacOS X), one test failed because of a shell
error:

        grep: is: No such file or directory
        grep: (ifnothtml|ifinfo|ifnottex): No such file or directory
        grep: text: No such file or directory
        FAIL: cond

Further examination shows:

        /usr/local/bin/egrep 'This is (ifnothtml|ifinfo|ifnottex) text' cond.out
        grep: is: No such file or directory
        grep: (ifnothtml|ifinfo|ifnottex): No such file or directory
        grep: text: No such file or directory
        ...

This is the latest alpha release of GNU grep

        /usr/local/bin/egrep --version
        egrep (GNU grep) 2.5.1
        ...

in which fgrep and egrep are shell scripts, instead of hard (or
symbolic) links to grep:

        % cat /usr/local/bin/egrep
        #!/bin/sh
        exec /usr/local/bin/grep -E ${1+"$@"}

The shell bug can be demonstrated with this script:

        % cat ~/bug4.sh
        #!/bin/sh
        set -
        echo $#
        set - ${1+"$@"}
        echo $#

On a system with a correctly-working shell, the output is

        % ~/bug4.sh "one" "two words" "three words here" "1 2 3 4"
        4
        4

On Apple Darwin, the quotes are lost, producing incorrect output:

        % ~/bug4.sh "one" "two words" "three words here" "1 2 3 4"
        4
        10

The O/S version is:

        % uname -a
        Darwin darwin.math.utah.edu 5.3 Darwin Kernel Version 5.3: Thu Jan 24 
22:06:02 PST 2002; root:xnu/xnu-201.19.obj~1/RELEASE_PPC  Power Macintosh 
powerpc

This error is NOT the fault of texinfo, but probably should be noted
in the texinfo release notes.  I consider the test failure harmless,
and did a "make install".

------------------------------------------------------------------------
(2) On GNU/Linux (Red Hat 6.2) on Intel x86 the build was successful
with gcc-2.95.3, but with the Portland Group compiler, pgcc, there was
a compilation failure:

pgcc -DINFODIR=\"/usr/local/info\" -DLOCALEDIR=\"/usr/local/share/locale\" 
-DHAVE_CONFIG_H -I. -I. -I.. -I. -I../lib -I../intl -I.. -I.  
-I/usr/local/include  -g -c `test -f m-x.c || echo './'`m-x.c
PGC-S-0098-Expression of type void * cannot be dereferenced (m-x.c: 151)
PGC-S-0056-Attempt to call non-function (m-x.c: 151)
PGC/x86 Linux/x86 3.3-1: compilation completed with severe errors

The statement in question is

    (*InfoFunction(command)) (active_window, count, 0);

Its preprocessor expansion is

    InfoCommand *command ;
    ...
    (*((command) ? (command)->func : ((void*)0)))(active_window,count,0);

The compilation error arises because the conditional can evaluate to
(*(void*)0).

The GNU compilers produce only a warning for this use:

        % cat foo.c
        int x = (*(void*)0);

        % gcc -c foo.c
        foo.c:1: warning: dereferencing `void *' pointer
        foo.c:1: void value not ignored as it ought to be
        foo.c:1: initializer element is not constant

        % g++ -c foo.c
        foo.c:1: void value not ignored as it ought to be

However, the Portland Group compilers diagnose a failure:

        % pgcc -c foo.c
        PGC-S-0098-Expression of type void * cannot be dereferenced (foo.c: 1)
        PGC-S-0074-Non-constant expression in initializer (foo.c: 1)
        PGC/x86 Linux/x86 3.3-1: compilation completed with severe errors

        % pgCC -c foo.c
        "foo.c", line 1: error: expression must be a pointer to a complete 
object type
          int x = (*(void*)0);
                    ^
        1 error detected in the compilation of "foo.c".

The Sun Solaris compilers also reject this:

        % cc -c foo.c
        "foo.c", line 1: initialization type mismatch
        "foo.c", line 1: non-constant initializer involving a cast
        cc: acomp failed for foo.c

        % CC -c foo.c
        "foo.c", line 1: Error: Cannot dereference a void*.
        1 Error(s) detected.

as does the Princeton/AT&T lcc compiler:

        % lcc -c foo.c
        foo.c:1: invalid initialization type; found `void' expected `int'
        foo.c:1: initializer must be constant

Section 3.1.2.5, p. 24, of ANSI X3.9.159-1989 (C89 Standard) says

        The \textbf{void} type comprises an empty set of values; it is
        an incomplete type that cannot be dereferenced.

The companion C89 Rationale says on p. 26

        ... a pointer to void may not be dereferenced.

I was curious as to why this code compiled elsewhere with non-gcc
compilers: examination of the preprocessor output on Sun Solaris shows
that it expands to

        (*((command) ? (command)->func : 0))(active_window,count,0);

This involves dereferencing NULL, about which C89 says in section
3.3.3.2 on p. 45:

        If an invalid value has been assigned to the pointer, the
        behavior of the unary * operator is undefined.
        \footnote{... Among the invalid values for dereferencing a
        pointer by the unary * operator are a null pointer,...}

Identical language appears in ISO/IEC 9899:1999 (C99 Standard) in
section 6.5.3.2 on p. 79.

texinfo is therefore erroneous in this definition in info/doc.h:

        #define InfoFunction(ic) ((ic) ? (ic)->func : NULL)
>
since the invocation

        (*InfoFunction(command)) (active_window, count, 0);

will dereference either 0 or a void* pointer if command is NULL.  Both
C89 and C99 say this is undefined, so the Portland Group compilers are
perfectly correct in rejecting the code.

InfoFunction is used 11 times in info/{infodoc,m-x,session}.c

What info/doc.h SHOULD probably say is

        static InfoCommand * dummy ( ) { return (InfoCommand*)NULL; }
        #define InfoFunction(ic) ((ic) ? (ic)->func : (VFunction*)dummy)

With that simple change, the Portland Group compiler, pgcc, compiles
m-x.c without errors or warnings, the build completes, and all 17
validation tests pass.
------------------------------------------------------------------------
(3) The Portland Group compiler, pgcc, raised warnings which are
traced to use of "unsigned char*" where "char*" is expected:

        % pgcc -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f infomap.c || 
echo './'`infomap.c
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1435)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1507)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1508)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1509)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1510)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1511)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1512)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1513)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1514)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1515)
        PGC-W-0095-Type cast required for this conversion (infomap.c: 1516)
PGC-W-0095-Type cast required for this conversion (infomap.c: 1518)

        % pgcc -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f infokey.c || 
echo './'`infokey.c
        PGC-W-0095-Type cast required for this conversion (infokey.c: 764)

It also complained:

        % pgcc -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
xml.c || echo './'`xml.c
        PGC-W-0089-Array name used in logical expression (xml.c: 572)
        PGC-W-0136-Function xml_insert_element has non-prototype declaration in 
scope (xml.c: 653)
        PGC-W-0095-Type cast required for this conversion (xml.c: 1228)
------------------------------------------------------------------------
(4) The SGI IRIX 6.5 native C compiler, which is the best
    diagnostician in my entire compiler collection (50+ C, 35+ C++),
    reports numerous type conflicts and unused variables:

        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f display.c || 
echo './'`display.c
        cc-1552 c89: WARNING File = display.c, Line = 53
          The variable "display_line" is set but never used.

            register DISPLAY_LINE *display_line;
                                   ^

        cc-1552 c89: WARNING File = display.c, Line = 319
          The variable "begin" is set but never used.

                        char *begin;
                              ^
        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f echo-area.c 
|| echo './'`echo-area.c
        cc-1552 c89: WARNING File = echo-area.c, Line = 1034
          The variable "start" is set but never used.

                          int start, pagetop;
                              ^

        cc-1164 c89: WARNING File = echo-area.c, Line = 1313
          Argument of type "int (*)()" is incompatible with parameter of type
                  "int (*)(const void *, const void *)".

                   compare_references);
                   ^

        cc-1552 c89: WARNING File = echo-area.c, Line = 1345
          The variable "old_pagetop" is set but never used.

            int old_pagetop;
                ^

        cc-1552 c89: WARNING File = echo-area.c, Line = 1491
          The variable "ready" is set but never used.

            int ready;
                ^
        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f infodoc.c || 
echo './'`infodoc.c
        cc-1552 c89: WARNING File = infodoc.c, Line = 36
          The variable "internal_info_help_node_contents" is set but never used.

          static char *internal_info_help_node_contents = (char *)NULL;
                       ^

        cc-1552 c89: WARNING File = infodoc.c, Line = 1056
          The variable "where_is_rep_index" is set but never used.

          static int where_is_rep_index = 0;
                     ^
        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f infomap.c || 
echo './'`infomap.c
        cc-1164 c89: WARNING File = infomap.c, Line = 1435
          Argument of type "unsigned char *" is incompatible with parameter of 
type
                  "const char *".

                if (len < INFOKEY_NMAGIC + strlen(VERSION) + 1 || 
strcmp(VERSION, buf + 4) != 0)
                                                                                
  ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1507
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_RIGHT_ARROW:    t = term_kr; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1508
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_LEFT_ARROW:     t = term_kl; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1509
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_UP_ARROW:       t = term_ku; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1510
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_DOWN_ARROW:     t = term_kd; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1511
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_PAGE_UP:        t = term_kP; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1512
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_PAGE_DOWN:      t = term_kN; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1513
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_HOME:           t = term_kh; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1514
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_END:            t = term_ke; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1515
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_DELETE:         t = term_kx; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1516
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                case SK_INSERT:         t = term_ki; break;
                                                          ^

        cc-1515 c89: WARNING File = infomap.c, Line = 1518
          A value of type "char *" cannot be assigned to an entity of type
                  "unsigned char *".

                                default:                t = lit; break;
                                                          ^

        cc-1174 c89: WARNING File = infomap.c, Line = 1555
          The variable "ke" was declared but never referenced.

                KEYMAP_ENTRY ke;
                             ^

        cc-1174 c89: WARNING File = infomap.c, Line = 1668
          The variable "map" was declared but never referenced.

            Keymap map;
                   ^

        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f nodemenu.c || 
echo './'`nodemenu.c
        cc-1164 c89: WARNING File = nodemenu.c, Line = 166
          Argument of type "int (*)()" is incompatible with parameter of type
                  "int (*)(const void *, const void *)".

                qsort (lines, lines_index, sizeof (char *), compare_strings);
                                                            ^
        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f session.c || 
echo './'`session.c
        cc-1552 c89: WARNING File = session.c, Line = 1491
          The variable "pagetop" is set but never used.

            int pagetop;
                ^

        cc-1552 c89: WARNING File = session.c, Line = 1979
          The variable "entry" is set but never used.

            register REFERENCE *entry, **menu;
                                ^

        cc-1552 c89: WARNING File = session.c, Line = 4362
          The variable "orig" is set but never used.

            NODE *orig;
                  ^

        cc-1552 c89: WARNING File = session.c, Line = 3354
          The variable "search_string_index" is set but never used.

          static int search_string_index = 0;
                     ^
        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f terminal.c || 
echo './'`terminal.c
        cc-1552 c89: WARNING File = terminal.c, Line = 104
          The variable "term_mm" is set but never used.

          static char *term_mm;
                       ^

        cc-1552 c89: WARNING File = terminal.c, Line = 107
          The variable "term_mo" is set but never used.

          static char *term_mo;
                       ^
        c89 -mips3 -O2 -DINFODIR=\"/usr/local/info\" 
-DLOCALEDIR=\"/usr/local/share/locale\" -DHAVE_CONFIG_H -I. -I. -I.. -I. 
-I../lib -I../intl -I.. -I.  -I/usr/local/include  -g -c `test -f infokey.c || 
echo './'`infokey.c
        cc-1174 c89: WARNING File = infokey.c, Line = 89
          The variable "initial_node" was declared but never referenced.

            NODE *initial_node;         /* First node loaded by Info. */
                  ^

        cc-1164 c89: WARNING File = infokey.c, Line = 764
          Argument of type "unsigned char *" is incompatible with parameter of 
type
                  "char *".

            strncpy (s->data + s->cur, str, len);
                     ^

        c89 -mips3 -O2 -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
defun.c || echo './'`defun.c
        cc-1185 c89: WARNING File = defun.c, Line = 710
          An enumerated type is mixed with another type.

            type = find_type_from_name (temp);
                 ^
        c89 -mips3 -O2 -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
index.c || echo './'`index.c
        cc-1164 c89: WARNING File = index.c, Line = 625
          Argument of type "int (*)()" is incompatible with parameter of type
                  "int (*)(const void *, const void *)".

            qsort (array, count, sizeof (INDEX_ELT *), index_element_compare);
                                                       ^

        c89 -mips3 -O2 -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
makeinfo.c || echo './'`makeinfo.c
        cc-1177 c89: WARNING File = makeinfo.c, Line = 1595
          The indicated argument is incompatible with the corresponding formal 
parameter.

                    tag_table = (TAG_ENTRY *) reverse_list (tag_table);
                                                            ^
        c89 -mips3 -O2 -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
xml.c || echo './'`xml.c
        cc-1116 c89: WARNING File = xml.c, Line = 1192
          Non-void function "xml_insert_indexterm" (declared at line 1149) 
should return
                  a value.

          }
          ^

        cc-1164 c89: WARNING File = xml.c, Line = 1228
          Argument of type "unsigned char *" is incompatible with parameter of 
type
                  "const char *".

            strncpy (tmp, output_paragraph, l);
                          ^
        c89 -mips3 -O2 -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
install-info.c || echo './'`install-info.c
        cc-1552 c89: WARNING File = install-info.c, Line = 1091
          The variable "infilelen_sans_info" is set but never used.

            unsigned infilelen_sans_info;
                     ^

        cc-1177 c89: WARNING File = install-info.c, Line = 1444
          The indicated argument is incompatible with the corresponding formal 
parameter.

                        lines = xrealloc (lines, (lines_allocated + 1)
                                          ^
        c89 -mips3 -O2 -DHAVE_CONFIG_H -I. -I. -I.. -I../lib -I../intl 
-DLOCALEDIR=\"/usr/local/share/locale\"  -I/usr/local/include  -g -c `test -f 
texindex.c || echo './'`texindex.c
        cc-1164 c89: WARNING File = texindex.c, Line = 1051
          Argument of type "int (*)()" is incompatible with parameter of type
                  "int (*)(const void *, const void *)".

                       compare_prepared);
                       ^

        cc-1164 c89: WARNING File = texindex.c, Line = 1059
          Argument of type "int (*)()" is incompatible with parameter of type
                  "int (*)(const void *, const void *)".

              qsort (linearray, nextline - linearray, sizeof (char *), 
compare_full);
                                                                       ^
------------------------------------------------------------------------

-------------------------------------------------------------------------------
- Nelson H. F. Beebe                    Tel: +1 801 581 5254                  -
- Center for Scientific Computing       FAX: +1 801 585 1640, +1 801 581 4148 -
- University of Utah                    Internet e-mail: address@hidden  -
- Department of Mathematics, 110 LCB        address@hidden  address@hidden -
- 155 S 1400 E RM 233                       address@hidden                    -
- Salt Lake City, UT 84112-0090, USA    URL: http://www.math.utah.edu/~beebe  -
-------------------------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]