gcc produces wrong code when optimizer (O1 O2 or O3) is used. The c-source showing the problem is generated by the flex lexical scanner. Applies to gcc versions 3.0.4, 3.3.5 and 3.4.4 (and maybe others not tested). Tested on Debian/Intel platforms only. On gcc 2.95 and multiple former versions of gcc, the problem does not occur.
Of course, we cannot guess what the issue is from your description.
Created attachment 9792 [details] Testcase. Unpack and make reproduces the bug Testcase requires flex (>= 2.5.4) lexical scanner to be installed
>How-To-Repeat: Unpack the attached archive, cd showbug, make. It will first compile the program, then process and display some test data. Prerequisites: You must have the flex lexical parser installed for this to work Expected behavior: Some HTML code shows up like <HTML lang="it"> <BODY> ... Actual behavior: The HTML appears crippled, the first character of many tags is missing, e.g. HTML ang="it"> BODY> ... >Fix: No fix is known to me, workaround is -O0 or using gcc 2.95
html_purify.l:24: warning: operation on `data' may be undefined
(In reply to comment #4) > html_purify.l:24: warning: operation on `data' may be undefined Does fixing that line help? It should look like: static void strtolower(char *data) { while (*data != '\0') { *data = tolower(*data); data++;} }
From the private email: Hello and thanks for the quick answer! Yes it does! But: I am not getting the warning: operation on `data' may be undefined when using gcc 3.4.4 and -Wall. So how could I (and someone else) find this type of error? Regards Friede PS: Wow! Never received an answer that fast!
(In reply to comment #6) > Hello and thanks for the quick answer! Yes it does! But: I am not getting the > warning: operation on `data' may be undefined > > when using gcc 3.4.4 and -Wall. Try at -O0, glibc changes tolower to a macro which causes issues with the warning, I will file another bug about that soon. The short testcase for your issue would be: #include <ctype.h> void strtolower(char *data) { while (*data != '\0') *data++ = tolower(*data); } *** This bug has been marked as a duplicate of 11751 ***