https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106529

            Bug ID: 106529
           Summary: existence of sincos is assumed
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tk at giga dot or.at
  Target Milestone: ---
              Host: NetBSD/amd64
            Target: NetBSD/amd64
             Build: NetBSD/amd64

Created attachment 53411
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53411&action=edit
second example

NetBSD does not provide sincos (perhaps it should).
gcc 12.1.0 reports warnings that make no sense here.

Example program 1:

# cat >> sincos.c
int main() {
return sincos();
}

# gcc -o sincos sincos.c
sincos.c: In function ‘main’:
sincos.c:2:8: warning: implicit declaration of function ‘sincos’
[-Wimplicit-function-declaration]
    2 | return sincos();
      |        ^~~~~~
sincos.c:1:1: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
  +++ |+#include <math.h>
    1 | int main() {
sincos.c:2:8: warning: incompatible implicit declaration of built-in function
‘sincos’ [-Wbuiltin-declaration-mismatch]
    2 | return sincos();
      |        ^~~~~~
sincos.c:2:8: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
sincos.c:2:8: error: too few arguments to function ‘sincos’

I agree that in general it is helpful to include math.h for sincos(), but not
on NetBSD, where sincos() is not provided by libc.

Even more confusing, the warning comes even when math.h is already included -
example 2:

# cat > sincos.c
#include <math.h>
int main() {
return sincos();
}
# gcc -o sincos sincos.c
sincos.c: In function ‘main’:
sincos.c:3:8: warning: implicit declaration of function ‘sincos’
[-Wimplicit-function-declaration]
    3 | return sincos();
      |        ^~~~~~
sincos.c:2:1: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
    1 | #include <math.h>
  +++ |+#include <math.h>
    2 | int main() {
sincos.c:3:8: warning: incompatible implicit declaration of built-in function
‘sincos’ [-Wbuiltin-declaration-mismatch]
    3 | return sincos();
      |        ^~~~~~
sincos.c:3:8: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
sincos.c:3:8: error: too few arguments to function ‘sincos’



Environment details:
# gcc -v
Using built-in specs.
COLLECT_GCC=/usr/pkg/gcc12/bin/gcc
COLLECT_LTO_WRAPPER=/usr/pkg/gcc12/libexec/gcc/x86_64--netbsd/12.1.0/lto-wrapper
Target: x86_64--netbsd
Configured with: ../gcc-12.1.0/configure --disable-libstdcxx-pch --enable-nls
--with-libiconv-prefix=/usr --enable-__cxa_atexit
--with-gxx-include-dir=/usr/pkg/gcc12/include/c++/ --disable-libssp
--enable-languages='c obj-c++ objc fortran c++' --enable-shared
--enable-long-long --with-local-prefix=/usr/pkg/gcc12 --enable-threads=posix
--with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/usr/pkg/lib
-Wl,-zrelro -Wl,-znow ' --without-zstd --with-arch=nocona --with-tune=nocona
--with-fpmath=sse --with-system-zlib --with-gnu-ld --with-ld=/usr/bin/ld
--with-gnu-as --with-as=/usr/bin/as --prefix=/usr/pkg/gcc12
--build=x86_64--netbsd --host=x86_64--netbsd --infodir=/usr/pkg/gcc12/info
--mandir=/usr/pkg/gcc12/man
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC) 

Running on NetBSD-9.99.99/amd64.

Savetemps:
/usr/pkg/gcc12/bin/gcc -v -save-temps sincos.c -o sincos 
Using built-in specs.
COLLECT_GCC=/usr/pkg/gcc12/bin/gcc
COLLECT_LTO_WRAPPER=/usr/pkg/gcc12/libexec/gcc/x86_64--netbsd/12.1.0/lto-wrapper
Target: x86_64--netbsd
Configured with: ../gcc-12.1.0/configure --disable-libstdcxx-pch --enable-nls
--with-libiconv-prefix=/usr --enable-__cxa_atexit
--with-gxx-include-dir=/usr/pkg/gcc12/include/c++/ --disable-libssp
--enable-languages='c obj-c++ objc fortran c++' --enable-shared
--enable-long-long --with-local-prefix=/usr/pkg/gcc12 --enable-threads=posix
--with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/usr/pkg/lib
-Wl,-zrelro -Wl,-znow ' --without-zstd --with-arch=nocona --with-tune=nocona
--with-fpmath=sse --with-system-zlib --with-gnu-ld --with-ld=/usr/bin/ld
--with-gnu-as --with-as=/usr/bin/as --prefix=/usr/pkg/gcc12
--build=x86_64--netbsd --host=x86_64--netbsd --infodir=/usr/pkg/gcc12/info
--mandir=/usr/pkg/gcc12/man
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.1.0 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'sincos' '-mtune=nocona'
'-march=nocona'
 /usr/pkg/gcc12/libexec/gcc/x86_64--netbsd/12.1.0/cc1 -E -quiet -v sincos.c
-mtune=nocona -march=nocona -fpch-preprocess -o sincos.i
ignoring nonexistent directory
"/usr/pkg/gcc12/lib/gcc/x86_64--netbsd/12.1.0/../../../../x86_64--netbsd/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/pkg/gcc12/lib/gcc/x86_64--netbsd/12.1.0/include
 /usr/pkg/gcc12/include
 /usr/pkg/gcc12/lib/gcc/x86_64--netbsd/12.1.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'sincos' '-mtune=nocona'
'-march=nocona'
 /usr/pkg/gcc12/libexec/gcc/x86_64--netbsd/12.1.0/cc1 -fpreprocessed sincos.i
-quiet -dumpbase sincos.c -dumpbase-ext .c -mtune=nocona -march=nocona -version
-o sincos.s
GNU C17 (GCC) version 12.1.0 (x86_64--netbsd)
        compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C17 (GCC) version 12.1.0 (x86_64--netbsd)
        compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ab1d70000bedd16cbf4ffd28defbd834
sincos.c: In function ‘main’:
sincos.c:3:8: warning: implicit declaration of function ‘sincos’
[-Wimplicit-function-declaration]
    3 | return sincos();
      |        ^~~~~~
sincos.c:2:1: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
    1 | #include <math.h>
  +++ |+#include <math.h>
    2 | int main() {
sincos.c:3:8: warning: incompatible implicit declaration of built-in function
‘sincos’ [-Wbuiltin-declaration-mismatch]
    3 | return sincos();
      |        ^~~~~~
sincos.c:3:8: note: include ‘<math.h>’ or provide a declaration of ‘sincos’
sincos.c:3:8: error: too few arguments to function ‘sincos’

Reply via email to