0

我正在使用 Linux 上的 GCC 8.2.0 和 Cygwin 上的 GCC 8.1.0 编译一些 C 代码(如果确实需要,将提供链接)(后者是自动 CI 构建)。

在 Linux 上,一切正常。在 Cygwin 上,我得到 - 其中包括 - 以下警告:

C:\Users\travis\build\eyalroz\ssb-dbgen\src\bm_utils.c: In function 'e_str':
C:\Users\travis\build\eyalroz\ssb-dbgen\src\bm_utils.c:199:5: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
     strncpy(dest + loc, strtmp, len);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\travis\build\eyalroz\ssb-dbgen\src\bm_utils.c:197:11: note: length computed here
     len = strlen(strtmp);
           ^~~~~~~~~~~~~~

C:\Users\travis\build\eyalroz\ssb-dbgen\src\build.c:697:5: warning: 'strncpy' specified bound 10 equals destination size [-Wstringop-truncation]
     strncpy(d->dayofweek, weekday_names[d->daynuminweek-1],D_DAYWEEK_LEN+1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Users\travis\build\eyalroz\ssb-dbgen\src\build.c:698:5: warning: 'strncpy' specified bound 10 equals destination size [-Wstringop-truncation]
     strncpy(d->month,month_names[d->monthnuminyear-1],D_MONTH_LEN+1);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

据我所知,我没有做任何事情,这在两种情况下都会导致不同的编译标志。为什么我只在一种环境中收到警告?会不会是 GCC 版本?

4

0 回答 0