Skip to content

discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] #880

@heitbaum

Description

@heitbaum

Since glibc-2.43:

For ISO C23, the functions bsearch, memchr, strchr, strpbrk, strrchr, strstr, wcschr, wcspbrk, wcsrchr, wcsstr and wmemchr that return pointers into their input arrays now have definitions as macros that return a pointer to a const-qualified type when the input argument is a pointer to a const-qualified type.

https://lists.gnu.org/archive/html/info-gnu/2026-01/msg00005.html

../../../src/share/getopt/getopt.c: In function 'share___getopt_internal':
../../../src/share/getopt/getopt.c:781:18: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  781 |     char *temp = my_index (optstring, c);
      |                  ^~~~~~~~
../../../src/flac/utils.c: In function 'flac__utils_get_channel_mask_tag':
../../../src/flac/utils.c:485:20: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
  485 |         if(0 == (p = strchr((const char *)object->data.vorbis_comment.comments[offset].entry, '='))) /* should never happen, but just in case */
      |                    ^
../../../src/flac/main.c: In function 'parse_option':
../../../src/flac/main.c:1137:43: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
 1137 |                                         p = strchr(option_argument, ',');
      |                                           ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions