Skip to content

CLANG18 compiler warnings with -O3 in renderer cmdl parser

Basic info

Bug description

Compiling with CLANG18 and OPTIM=3 has some warnings in the renderer about string truncation:

    inlined from 'parseLfePositionConfig' at apps/renderer.c:2595:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound 1024 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'strncpy',
    inlined from 'parseAcousticEnvironmentIds' at apps/renderer.c:2636:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound 1024 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'strncpy',
    inlined from 'defaultArgs' at apps/renderer.c:2754:5,
    inlined from 'parseCmdlnArgs' at apps/renderer.c:3024:22,
    inlined from 'main' at apps/renderer.c:842:22:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound 4096 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'strncpy',
    inlined from 'setupWithSingleFormatInput' at apps/renderer.c:646:5,
    inlined from 'main' at apps/renderer.c:929:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'strncat',
    inlined from 'parseSceneDescriptionFile' at apps/renderer.c:3915:5,
    inlined from 'main' at apps/renderer.c:924:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:138:10: warning: '__builtin___strncat_chk' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
  138 |   return __builtin___strncat_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
apps/renderer.c: In function 'main':
apps/renderer.c:3280:37: note: length computed here
 3280 |     *wavFileNameLength = (uint32_t) strlen( wavFileName );
      |                                     ^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:548,
                 from apps/renderer.c:37:
In function 'strncat',
    inlined from 'parseMasa' at apps/renderer.c:3676:5,
    inlined from 'parseMetadata' at apps/renderer.c:3849:13,
    inlined from 'parseSceneDescriptionFile' at apps/renderer.c:3917:5,
    inlined from 'main' at apps/renderer.c:924:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:138:10: warning: '__builtin___strncat_chk' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
  138 |   return __builtin___strncat_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
apps/renderer.c: In function 'main':
apps/renderer.c:3676:5: note: length computed here
 3676 |     strncat( fullpath, inDir, strlen( inDir ) );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:548,
                 from apps/renderer.c:37:
In function 'strncat',
    inlined from 'parseIsm' at apps/renderer.c:3545:9,
    inlined from 'parseMetadata' at apps/renderer.c:3839:13,
    inlined from 'parseSceneDescriptionFile' at apps/renderer.c:3917:5,
    inlined from 'main' at apps/renderer.c:924:9:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:138:10: warning: '__builtin___strncat_chk' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
  138 |   return __builtin___strncat_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  139 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
apps/renderer.c: In function 'main':
apps/renderer.c:3545:9: note: length computed here
 3545 |         strncat( fullpath, inDir, strlen( inDir ) );
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/string.h:548,
                 from apps/isar_post_rend.c:36:
In function 'strncpy',
    inlined from 'defaultArgs' at apps/isar_post_rend.c:457:5,
    inlined from 'parseCmdlnArgs' at apps/isar_post_rend.c:585:22,
    inlined from 'main' at apps/isar_post_rend.c:875:22:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' specified bound 4096 equals destination size [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~
In function 'strncpy',
    inlined from 'main' at apps/isar_post_rend.c:906:5:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:95:10: warning: '__builtin_strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
   95 |   return __builtin___strncpy_chk (__dest, __src, __len,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   96 |       __glibc_objsize (__dest));
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~

It is unclear to me what this really means, but might make sense to take a look.

Ways to reproduce

Build with CLANG18 and OPTIM=3 set in Makefile