This is the mail archive of the gcc-patches@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] |
The optimizer is converting cp = strstr (s, ""); to just cp = s; Unfortunately, the argument s to strstr is const char *, and the result of strstr is char *, so we have a type mismatch here after optimization. This generates a spurious warning when compiled with -Wall. The solution here is easy. We just need to convert the argument to the result type before returning it, so that effectively we are generating cp = (char *) s; This is a regression from gcc-3.4. This was broken between gcc-3.4 and gcc-4.0, presumably as part of the tree-ssa work. In gcc-3.4, fold_builtin_strstr returns rtx. In gcc-4.0, it returns a tree. When converted, we missed the fact that we needed to add a type conversion in one place. I scanned the rest of the code in builtins.c, but did not find any other similar place that needed a fix. This was tested with a mainline C and C++ bootstrap on an x86_64-linux system, and gcc-4.0.x C and C++ bootstrap on an i386-freebsd4.10 system. There were no regressions. -- Jim Wilson, GNU Tools Support, http://www.specifix.com
Attachment:
patch.strstr.warning
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |