Skip to content

New compiler warnings about modifying 'const' object (STRING_PTR_RO) #6656

@MichaelChirico

Description

@MichaelChirico

valP[k++] = STRING_PTR_RO(item);

xd = STRING_PTR_RO(PROTECT(coerceUtf8IfNeeded(x))); nprotect++;

The compiler (on GitHub codespaces) warns at these two places:

chmatch.c: In function ‘chmatchMain’:
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include    -fpic  -fopenmp -std=c11 -O3 -pipe -Wall -pedantic -Wstrict-prototypes -isystem /usr/share/R/include  -fno-common -c subset.c -o subset.o
coalesce.c: In function ‘coalesce’:
chmatch.c:43:8: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
   43 |     xd = STRING_PTR_RO(PROTECT(coerceUtf8IfNeeded(x))); nprotect++;
      |        ^
gcc -I"/usr/local/lib/R/include" -DNDEBUG   -I/usr/local/include    -fpic  -fopenmp -std=c11 -O3 -pipe -Wall -pedantic -Wstrict-prototypes -isystem /usr/share/R/include  -fno-common -c transpose.c -o transpose.o
coalesce.c:159:17: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  159 |       valP[k++] = STRING_PTR_RO(item);
      |                 ^

The chmatch.c one is easy to fix (by instantiating xd as const), I'm less clear on how to fix the coalesce issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions