This is the mail archive of the gcc-bugs@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]

[Bug c/29674] New: strtok_r function prototype does not match function definition


Sees:
When compiling using the -Wconversion flag the strtok_r the comppiler complains
with a 
"""
warning: passing argument 2 of ?__strtok_r_1c? with different width due to
prototype
"""
Expects:
No warning when the -Wconversion option is specified

System Info:
  gcc (GCC) 4.1.1 20061011 (Red Hat 4.1.1-30)
  Linux brioja.netronome.com 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:37:32 EDT  
 2006 i686 i686 i386 GNU/Linux
Also exists in:
  gcc34 (GCC) 3.4.6 20060404 (Red Hat 3.4.6-4)

Compile and run options:
[brioja@brioja test]$ make && ./hello 
if gcc -DPACKAGE_NAME=\"Hello\ Program\" -DPACKAGE_TARNAME=\"hello\"
-DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"Hello\ Program\ 1.0\"
-DPACKAGE_BUGREPORT=\"Author\ Of\ The\ Program\ \<aotp@zxcv.com\>\"
-DPACKAGE=\"hello\" -DVERSION=\"1.0\"  -I. -I.    -Wconversion -g -O2 -MT
hello.o -MD -MP -MF ".deps/hello.Tpo" -c -o hello.o hello.c; \
        then mv -f ".deps/hello.Tpo" ".deps/hello.Po"; else rm -f
".deps/hello.Tpo"; exit 1; fi
hello.c: In function ?main?:
hello.c:10: warning: passing argument 2 of ?__strtok_r_1c? with different width
due to prototype
gcc -Wconversion -g -O2   -o hello  hello.o  
aaaa
[brioja@brioja test]$ 

For source code hello.c:
#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main()
{
  const char* delim = "xy";
  char str[] = "aaaaxbbbbyccccc";
  char *saved;
  printf("%s\n",strtok_r(str, delim, &saved));
  return 0;
}

Works for strtok():
Regular strtok()'s function prototype matches its definiton.

#include <unistd.h>
#include <stdio.h>
#include <string.h>

int main()
{
  const char* delim = "xy";
  char str[] = "aaaaxbbbbyccccc";
  printf("%s\n",strtok(str, delim));
  return 0;
}

Note: 
Could the wrong function be being called? __strtok_r_1c sounds like a "1
character" function.


-- 
           Summary: strtok_r function prototype does not match function
                    definition
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: brandon at rioja dot us
 GCC build triplet: i686-redhat-linux-gnu
  GCC host triplet: i686-redhat-linux-gnu
GCC target triplet: i686-redhat-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29674


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