https://sourceware.org/bugzilla/show_bug.cgi?id=29194
Bug ID: 29194 Summary: bfd/doc/chew.c error: ISO C forbids conversion of function pointer to object pointer type Product: binutils Version: 2.38 Status: UNCONFIRMED Severity: normal Priority: P2 Component: binutils Assignee: unassigned at sourceware dot org Reporter: dc at genunix dot com Target Milestone: --- Not entirely sure if this is a bug or perhaps the binutils sources are not C99 clean. Also not sure if this is a Big Flipping Deal[1] or maybe I can give up on C99? Regardless I have CFLAGS set for strict compliance : mimas$ echo $CC /opt/gcc/imed/gcc12/bin/gcc mimas$ echo $CFLAGS -std=iso9899:1999 -pedantic -pedantic-errors -fno-builtin -g -O0 -m64 -march=k8 -mtune=k8 -malign-double -mpc80 -mno-mmx -Wl,-rpath=/opt/bw/lib,--enable-new-dtags mimas$ echo $CPPFLAGS -I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE mimas$ This is on an old Red Hat Enterprise Linux 6 machine wherein I did a bootstrap of GCC 9.4.0 and then used that result to bootstrap GCC 12.1.0 with great success. So I figure the compiler is reasonable. Configure was trivial : mimas$ ../binutils-2.38/configure --prefix=/opt/bw --enable-ld --with-gmp=/opt/bw --with-mpfr=/opt/bw --with-mpc=/opt/bw --with-isl=/opt/bw checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether ln works... yes checking whether ln -s works... yes checking for a sed that does not truncate output... /bin/sed checking for gawk... gawk checking for gcc... /opt/gcc/imed/gcc12/bin/gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether /opt/gcc/imed/gcc12/bin/gcc accepts -g... yes checking for /opt/gcc/imed/gcc12/bin/gcc option to accept ISO C89... none needed checking for /opt/gcc/imed/gcc12/bin/gcc option to accept ISO C99... none needed checking whether we are using the GNU C++ compiler... yes checking whether /opt/gcc/imed/gcc12/bin/g++ accepts -g... yes checking whether g++ accepts -static-libstdc++ -static-libgcc... yes checking for gnatbind... no checking for gnatmake... no checking whether compiler driver understands Ada... no checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2 checking for objdir... .libs checking for isl 0.15 or later... yes checking for default BUILD_CONFIG... checking for --enable-vtable-verify... no checking for bison... bison -y checking for bison... bison checking for gm4... /opt/bw/bin/m4 checking for flex... flex checking for flex... flex checking for makeinfo... makeinfo checking for expect... no checking for runtest... no checking for ar... (cached) /opt/bw/bin/gar checking for as... (cached) /opt/bw/bin/gas checking for dlltool... no checking for ld... (cached) /opt/bw/bin/gld checking for lipo... no checking for nm... (cached) /opt/bw/bin/gnm checking for ranlib... (cached) /opt/bw/bin/granlib checking for strip... (cached) /opt/bw/bin/gstrip checking for windres... no checking for windmc... no checking for objcopy... (cached) /opt/bw/bin/gobjcopy checking for objdump... (cached) /opt/bw/bin/gobjdump checking for readelf... (cached) /opt/bw/bin/greadelf checking for -plugin option... --plugin /opt/gcc/imed/gcc12/libexec/gcc/x86_64-pc-linux-gnu/12.1.0/liblto_plugin.so checking for cc... cc checking for c++... c++ checking for gcc... gcc checking for gfortran... gfortran checking for gccgo... no checking for ar... ar checking for as... as checking for dlltool... no checking for ld... ld checking for lipo... no checking for nm... nm checking for objcopy... objcopy checking for objdump... objdump checking for ranlib... ranlib checking for readelf... readelf checking for strip... strip checking for windres... no checking for windmc... no checking where to find the target ar... just compiled checking where to find the target as... just compiled checking where to find the target cc... host tool checking where to find the target c++... host tool checking where to find the target c++ for libstdc++... host tool checking where to find the target dlltool... just compiled checking where to find the target gcc... host tool checking where to find the target gfortran... host tool checking where to find the target gccgo... host tool checking where to find the target ld... just compiled checking where to find the target lipo... host tool checking where to find the target nm... just compiled checking where to find the target objcopy... just compiled checking where to find the target objdump... just compiled checking where to find the target ranlib... just compiled checking where to find the target readelf... just compiled checking where to find the target strip... just compiled checking where to find the target windres... just compiled checking where to find the target windmc... just compiled checking whether to enable maintainer-specific portions of Makefiles... no configure: creating ./config.status config.status: creating Makefile mimas$ I had a previous build of binutils 2.38 already done and sitting in the /opt/bw/bin directory with a prefix letter 'g'. I needed them to do a bootstrap of gcc 9.4.0 as well as gcc 12.1.0. The letter 'g' prefix is to separate them from the crusty old stuff in the Red Hat system directory /usr/bin. For the sake of looking at it : mimas$ /usr/bin/as --version GNU assembler version 2.20.51.0.2-5.11.el6 20091009 Copyright 2009 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or later. This program has absolutely no warranty. This assembler was configured for a target of `x86_64-redhat-linux'. mimas$ Whereas I have : mimas$ /opt/bw/bin/gas --version GNU assembler (GNU Binutils) 2.38 Copyright (C) 2022 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or later. This program has absolutely no warranty. This assembler was configured for a target of `x86_64-pc-linux-gnu'. mimas$ I also have some env vars set : ADDR2LINE=/opt/bw/bin/gaddr2line AR=/opt/bw/bin/gar AS=/opt/bw/bin/gas _=/bin/env CC=/opt/gcc/imed/gcc12/bin/gcc CFLAGS=-std=iso9899:1999 -pedantic -pedantic-errors -fno-builtin -g -O0 -m64 -march=k8 -mtune=k8 -malign-double -mpc80 -mno-mmx -Wl, -rpath=/opt/bw/lib,--enable-new-dtags COLUMNS=132 CPPFLAGS=-I/opt/bw/include -D_POSIX_PTHREAD_SEMANTICS -D_LARGEFILE64_SOURCE CXXFLAGS=-g -O0 -fno-builtin -m64 -march=k8 -mtune=k8 -Wl,-rpath=/opt/bw/lib,--enable-new-dtags CXX=/opt/gcc/imed/gcc12/bin/g++ EDITOR=/bin/vi ELFEDIT=/opt/bw/bin/gelfedit GPROF=/opt/bw/bin/ggprof HISTCONTROL=ignoredups HISTORY=128 HISTSIZE=1000 HOME=/home/dclarke HOSTNAME=mimas.genunix.com LANG=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_NUMERIC=en_US.UTF-8 LC_TIME=en_US.UTF-8 LDFLAGS=-L/opt/bw/lib LD=/opt/bw/bin/gld LD_RUN_PATH=/opt/bw/lib LESS_IS_MORE=1 LINES=42 LOGNAME=dclarke M4=/opt/bw/bin/m4 MAIL=/var/spool/mail/dclarke MANPATH=/usr/share/man:/opt/schily/share/man NICE=/bin/nice NM=/opt/bw/bin/gnm OBJCOPY=/opt/bw/bin/gobjcopy OBJDUMP=/opt/bw/bin/gobjdump OLDPWD=/opt/bw/build PAGER=/bin/more PATH=/opt/gcc/imed/gcc12/bin:/opt/bw/bin:/opt/bw/sbin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin PWD=/opt/bw/build/binutils-2.38_rhel6_amd64.002 RANLIB=/opt/bw/bin/granlib READELF=/opt/bw/bin/greadelf SHELL=/bin/bash SHLVL=2 SIZE=/opt/bw/bin/gsize STRINGS=/opt/bw/bin/gstrings STRIP=/opt/bw/bin/gstrip TERM_PROGRAM=tmux TERM_PROGRAM_VERSION=3.2a TERM=screen TIME=/usr/bin/time TMPDIR=/var/tmp/dclarke TMUX_PANE=%1 TMUX=/var/tmp/dclarke/default,2891,0 TZ=GMT0 USER=dclarke VISUAL=/bin/vi XTERM_LOCALE=en_US.UTF-8 XTERM_SHELL=/usr/bin/bash A few of the above are just 'nice to have' around. Such as TIME and NICE which can sometimes be a shell built in and sometimes a binary in a few different places on different machines and OS types. So I use them for the compile and testing like so : $TIME -p $NICE -n +15 make . . . make[2]: Entering directory `/opt/bw/build/binutils-2.38_rhel6_amd64.002/bfd' GEN bfdver.h GEN elf32-target.h GEN elf64-target.h GEN targmatch.h Making info in doc make[3]: Entering directory `/opt/bw/build/binutils-2.38_rhel6_amd64.002/bfd/doc' /opt/gcc/imed/gcc12/bin/gcc -o chw$$ -std=iso9899:1999 -pedantic -pedantic-errors -fno-builtin -g -O0 -m64 -march=k8 -mtune=k8 -malign-double -mpc80 -mno-mmx -Wl,-rpath=/opt/bw/lib,--enable-new-dtags \ -L/opt/bw/lib -I.. -I../../../binutils-2.38/bfd/doc/.. -I../../../binutils-2.38/bfd/doc/../../include -I../../../binutils-2.38/bfd/doc/../../intl -I../../intl ../../../binutils-2.38/bfd/doc/chew.c; \ /bin/sh ../../../binutils-2.38/bfd/doc/../../move-if-change \ chw$$ chew; \ touch chew.stamp ../../../binutils-2.38/bfd/doc/chew.c: In function 'call': ../../../binutils-2.38/bfd/doc/chew.c:386:7: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic] 386 | e = (dict_type *) (pc[1]); | ^ ../../../binutils-2.38/bfd/doc/chew.c: In function 'free_words': ../../../binutils-2.38/bfd/doc/chew.c:1268:23: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedanti c] 1268 | free ((char *) ptr->code[i + 1] - 1); | ^ ../../../binutils-2.38/bfd/doc/chew.c: In function 'add_intrinsic': ../../../binutils-2.38/bfd/doc/chew.c:1349:32: error: implicit declaration of function 'strdup'; did you mean 'strcmp'? [-Wimplicit- function-declaration] 1349 | dict_type *new_d = newentry (strdup (name)); | ^~~~~~ | strcmp ../../../binutils-2.38/bfd/doc/chew.c:1349:32: error: passing argument 1 of 'newentry' makes pointer from integer without a cast [-Wint-conversion] 1349 | dict_type *new_d = newentry (strdup (name)); | ^~~~~~~~~~~~~ | | | int ../../../binutils-2.38/bfd/doc/chew.c:1315:12: note: expected 'char *' but argument is of type 'int' 1315 | char *word; | ^~~~ ../../../binutils-2.38/bfd/doc/chew.c: In function 'add_var': ../../../binutils-2.38/bfd/doc/chew.c:1360:29: error: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic] 1360 | add_to_definition (new_d, (stinst_type) (&(new_d->var))); | ^ ../../../binutils-2.38/bfd/doc/chew.c: In function 'compile': ../../../binutils-2.38/bfd/doc/chew.c:1409:43: error: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic] 1409 | add_to_definition (ptr, (stinst_type) (word + 1)); | ^ ../../../binutils-2.38/bfd/doc/chew.c:1429:43: error: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic] 1429 | add_to_definition (ptr, (stinst_type) lookup_word (word)); | ^ mv: cannot stat `chw4905': No such file or directory GEN aoutx.stamp /bin/sh: ./chew: No such file or directory make[3]: *** [aoutx.stamp] Error 1 make[3]: Leaving directory `/opt/bw/build/binutils-2.38_rhel6_amd64.002/bfd/doc' make[2]: *** [info-recursive] Error 1 make[2]: Leaving directory `/opt/bw/build/binutils-2.38_rhel6_amd64.002/bfd' make[1]: *** [all-bfd] Error 2 make[1]: Leaving directory `/opt/bw/build/binutils-2.38_rhel6_amd64.002' make: *** [all] Error 2 real 89.23 user 60.85 sys 24.83 mimas$ Seems to be NOT strict C99 and I wonder if binutils actually is or not? -- Dennis Clarke RISC-V/SPARC/PPC/ARM/CISC UNIX and Linux spoken GreyBeard and suspenders optional [1] BFD is the "Binary File Descriptor" library. The name came from a conversation David Wallace was having with Richard Stallman about the library: RMS said that it would be quite hard—David said “BFD”. Stallman was right, but the name stuck. -- You are receiving this mail because: You are on the CC list for the bug.