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 optimization/12227] New: wrong calling of functions in certain circumstances (see the sample code)


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: wrong calling of functions in certain circumstances (see
                    the sample code)
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: l_belev at yahoo dot com
                CC: gcc-bugs at gcc dot gnu dot org

/*
 * this sample should print AbCdEf and does it
 * when it's compiled with -O0 or -O3, but when
 * it's compiled with -O1 or -O2, it incorrectly
 * prints ABCDEF. I looked at the generated assembler
 * code, and obviously it's erroneous.
 * (the external func putchar does not interfere with
 * this gcc bug - without it the generated code is bad too)
 */

int lower(int x) { return x + 'a'; }
int upper(int x) { return x + 'A'; }

int main()
{
	int k;

	for (k = 0; k < 6; k++)
		putchar(((k & 1) ? lower : upper)(k));

	putchar('\n');
	return 0;
}


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