This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Weird compiler error [-Werror=discarded-qualifiers], though correct IMO


I wonder why the compiler (v9) complains below.
Is this maybe an abi issue?


gcc-latest -c -DHAVE_CONFIG_H -pipe -Wextra -Werror -Wpedantic -g0 -DNDEBUG -Ofast -I. -I../../gcc_trunk/libiberty/../include -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -Wshadow=local -pedantic -D_GNU_SOURCE -fpic ../../gcc_trunk/libiberty/cplus-dem.c -o pic/cplus-dem.o


../../gcc_trunk/libiberty/cplus-dem.c: In function 'cplus_demangle_opname':
../../gcc_trunk/libiberty/cplus-dem.c:661:16: error: passing argument 1 of 'strlen' discards 'const' qualifier from pointer target type [-Werror=discarded-qualifiers]
   len = strlen(opname);
                ^~~~~~
In file included from ../../gcc_trunk/libiberty/cplus-dem.c:48:
/usr/include/string.h:399:35: note: expected 'char *' but argument is of type 'const char *'
 extern size_t strlen (const char *__s)
                             ~~~~~~^~~


libiberty/cplus-dem.c:
----------------------

int
cplus_demangle_opname (const char *opname, char *result, int options)
{
  int len, len1, ret;
  string type;
  struct work_stuff work[1];
  const char *tem;

  len = strlen(opname);
...



/usr/include/string.h:
----------------------

__BEGIN_NAMESPACE_STD
/* Return the length of S.  */
extern size_t strlen (const char *__s)
     __THROW __attribute_pure__ __nonnull ((1));
__END_NAMESPACE_STD



--
PS: was erronously sent to gcc-help-owner@gcc.gnu.org  :-)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]