Hi,
thanks for reporting it.

That's a real error inside the #ifdef _WIN32

char homepath[MAX_PATH]; is allocated as temporary array inside the block,
but then referenced outside when it's not valid anymore.

Would you like to send a fix in gerrit?
I will not have time to do it before tomorrow.

Antonio

On Fri, Jun 17, 2022, 06:10 Dietmar May <dietmar....@outlook.com> wrote:

> When compiling openocd - master (commit 480d4e1) using msys64/mingw32, I
> get the following error and the build aborts:
>
> src/helper/configuration.c: In function 'get_home_dir':
> src/helper/configuration.c:182:29: error: dangling pointer 'home' to
> 'homepath' may be used [-Werror=dangling-pointer=]
>    182 |                 home_path = alloc_printf("%s/%s", home,
> append_path);
>        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> src/helper/configuration.c:160:30: note: 'homepath' declared here
>    160 |                         char homepath[MAX_PATH];
>        |                              ^~~~~~~~
> src/helper/configuration.c:184:29: error: dangling pointer 'home' to
> 'homepath' may be used [-Werror=dangling-pointer=]
>    184 |                 home_path = alloc_printf("%s", home);
>        |                             ^~~~~~~~~~~~~~~~~~~~~~~~
> src/helper/configuration.c:160:30: note: 'homepath' declared here
>    160 |                         char homepath[MAX_PATH];
>        |                              ^~~~~~~~
> cc1.exe: all warnings being treated as errors
> make[2]: *** [Makefile:3503: src/helper/configuration.lo] Error 1
>
> configure has been run using
>
> --host=i686-w64-mingw32
>
> Looks like mingw32 is pulling in gcc 12.1 now:
>
> pacman -Q | grep mingw-w64-i686-gcc
>
> mingw-w64-i686-gcc 12.1.0-2
>
> I was able to compile by downgrading to gcc 11.2.0-9
>
> wget
>
> https://repo.msys2.org/mingw/i686/mingw-w64-i686-gcc-11.2.0-9-any.pkg.tar.zst.sig
>
> wget
>
> https://repo.msys2.org/mingw/i686/mingw-w64-i686-gcc-libs-11.2.0-9-any.pkg.tar.zst
>
> pacman -U mingw-w64-i686-gcc-11.2.0-9-any.pkg.tar.zst
> mingw-w64-i686-gcc-libs-11.2.0-9-any.pkg.tar.zst
>
>
>


Reply via email to