joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.79k stars 382 forks source link

GCC 14 Build Failure: speexdsp/fftwrap.c: passing argument 2 of ‘spx_fft’ from incompatible pointer type #4865

Closed Leo3418 closed 8 months ago

Leo3418 commented 8 months ago

Describe the bug

DOSBox-X 2024.03.01 fails to build with GCC 14 using the build-sdl2 script. This bug has been reproduced on both Gentoo (https://bugs.gentoo.org/921909) and Fedora 40 (pre-release now, but this issue should be caused by GCC 14 rather than a pre-release distro version).

speexdsp/fftwrap.c: In function ‘spx_fft_float’:
speexdsp/fftwrap.c:388:19: error: passing argument 2 of ‘spx_fft’ from incompatible pointer type [-Wincompatible-pointer-types]
  388 |    spx_fft(table, _in, _out);
      |                   ^~~
      |                   |
      |                   spx_word16_t * {aka short int *}
speexdsp/fftwrap.c:102:34: note: expected ‘float *’ but argument is of type ‘spx_word16_t *’ {aka ‘short int *’}
  102 | void spx_fft(void *table, float *in, float *out)
      |                           ~~~~~~~^~
speexdsp/fftwrap.c:388:24: error: passing argument 3 of ‘spx_fft’ from incompatible pointer type [-Wincompatible-pointer-types]
  388 |    spx_fft(table, _in, _out);
      |                        ^~~~
      |                        |
      |                        spx_word16_t * {aka short int *}
speexdsp/fftwrap.c:102:45: note: expected ‘float *’ but argument is of type ‘spx_word16_t *’ {aka ‘short int *’}
  102 | void spx_fft(void *table, float *in, float *out)
      |                                      ~~~~~~~^~~
speexdsp/fftwrap.c: In function ‘spx_ifft_float’:
speexdsp/fftwrap.c:424:20: error: passing argument 2 of ‘spx_ifft’ from incompatible pointer type [-Wincompatible-pointer-types]
  424 |    spx_ifft(table, _in, _out);
      |                    ^~~
      |                    |
      |                    spx_word16_t * {aka short int *}
speexdsp/fftwrap.c:120:35: note: expected ‘float *’ but argument is of type ‘spx_word16_t *’ {aka ‘short int *’}
  120 | void spx_ifft(void *table, float *in, float *out)
      |                            ~~~~~~~^~
speexdsp/fftwrap.c:424:25: error: passing argument 3 of ‘spx_ifft’ from incompatible pointer type [-Wincompatible-pointer-types]
  424 |    spx_ifft(table, _in, _out);
      |                         ^~~~
      |                         |
      |                         spx_word16_t * {aka short int *}
speexdsp/fftwrap.c:120:46: note: expected ‘float *’ but argument is of type ‘spx_word16_t *’ {aka ‘short int *’}
  120 | void spx_ifft(void *table, float *in, float *out)
      |                                       ~~~~~~~^~~

Steps to reproduce the behaviour

This issue can be reproduced in a Fedora 40 Docker container. I used Podman, but Docker should work the same.

$ podman run -it fedora:40 /bin/bash

Inside the container, run:

# dnf group install "C Development Tools and Libraries"
# dnf install SDL_net-devel SDL2_net-devel libxkbfile-devel ncurses-devel libpcap-devel libslirp-devel libpng-devel fluidsynth-devel freetype-devel nasm
# dnf install libXext-devel
# dnf install git
# git clone --depth 1 --branch dosbox-x-v2024.03.01 https://github.com/joncampbell123/dosbox-x.git
# cd dosbox-x/
# ./build-sdl2

Expected behavior

The build completes without any error.

What operating system(s) this bug have occurred on?

fedora:40 Docker image (https://hub.docker.com/layers/library/fedora/40/images/sha256-5f48188999a2ef1bebb855874e5eb5913efe8a5e7afc77006b5e42bc2cbe9bc2)

What version(s) of DOSBox-X have this bug?

2024.03.01 SDL2, tag dosbox-x-v2024.03.01

Used configuration

$ gcc --version
gcc (GCC) 14.0.1 20240228 (Red Hat 14.0.1-0)
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="40 (Container Image Prerelease)"
ID=fedora
VERSION_ID=40
VERSION_CODENAME=""
PLATFORM_ID="platform:f40"
PRETTY_NAME="Fedora Linux 40 (Container Image Prerelease)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:40"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f40/system-administrators-guide/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=40
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=40
SUPPORT_END=2025-05-13
VARIANT="Container Image"
VARIANT_ID=container

Output log

Please see "full build log" in "Additional information"

Additional information

Full build log

Have you checked that no similar bug report(s) exist?

Code of Conduct & Contributing Guidelines

asarubbo commented 8 months ago

To reproduce the bug is enough to use -Werror=incompatible-pointer-types as CFLAGS. It should work with previous gcc versions.

The difference is that in gcc-14, incompatible-pointer-types are turned into errors while previously they where only warnings.

maron2000 commented 8 months ago

The library is imported from https://www.speex.org/ so you may want to report this bug to the authors.

rderooy commented 8 months ago

FYI, this issue broke the RPM COPR build for the Fedora 40 Beta.

maron2000 commented 8 months ago

From the information provided by @asarubbo, to add -Wno-error=incompatible-pointer-types to the CXXFLAGS may work.

Leo3418 commented 6 months ago

The library is imported from https://www.speex.org/ so you may want to report this bug to the authors.

https://gitlab.xiph.org/xiph/speexdsp/-/issues/13