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

            Bug ID: 105935
           Summary: libgfortran build fails if HAVE_VSNPRINTF test fails
           Product: gcc
           Version: 10.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: phil at krylov dot eu
                CC: jb at gcc dot gnu.org
  Target Milestone: ---

The commit edaaef601d0d6d263fba87b42d6d04c99dd23dba [1] transforms st_vprintf()
function in libgfortran/into gf_vsnprintf() and #ifndefs it out [2]. It seems
the code has never been finished, but I've luckily created an environment where
HAVE_VSNPRINTF test fails (mingw-w64 10.0, see the respective ticket [3]), and:

/usr/ports/lang/gcc10/work-i686_w64_mingw32/gcc-10.3.0/libgfortran/runtime/error.c:
In function 'gf_vsnprintf':
/usr/ports/lang/gcc10/work-i686_w64_mingw32/gcc-10.3.0/libgfortran/runtime/error.c:145:22:
error: 'buffer' undeclared (first use in this function)
  145 |   written = vsprintf(buffer, format, ap);
      |                      ^~~~~~
/usr/ports/lang/gcc10/work-i686_w64_mingw32/gcc-10.3.0/libgfortran/runtime/error.c:145:22:
note: each undeclared identifier is reported only once for each function it
appears in
/usr/ports/lang/gcc10/work-i686_w64_mingw32/gcc-10.3.0/libgfortran/runtime/error.c:147:15:
warning: comparison of integer expressions of different signedness: 'int' and
'size_t' {aka 'unsigned int'} [-Wsign-compare]
  147 |   if (written >= size - 1)
      |               ^~
/usr/ports/lang/gcc10/work-i686_w64_mingw32/gcc-10.3.0/libgfortran/runtime/error.c:141:21:
warning: unused parameter 'str' [-Wunused-parameter]
  141 | gf_vsnprintf (char *str, size_t size, const char *format, va_list ap)
      |               ~~~~~~^~~
gmake[6]: *** [Makefile:2802: error.lo] Error 1


By the way, even after renaming `str` argument to `buffer` as was probably
intended, the #ifndefed-out code seems quite dangerous by modern standards (it
ignores the buffer size, lets vsprintf() produce a buffer overrun, and only
then reports it).


[1]
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=edaaef601d0d6d263fba87b42d6d04c99dd23dba

[2]
https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff;f=libgfortran/runtime/error.c;h=b07a4c0b12a57e93ee4546c074cfc2b081f49e5d;hp=1e8b6223aca5683c9721b4fec7b33fbd6275a6f1;hb=edaaef601d0d6d263fba87b42d6d04c99dd23dba;hpb=5b4dd0158308d1a3effffd6316f1b39fdd1ad120

[3] https://sourceforge.net/p/mingw-w64/bugs/935/

Reply via email to