http://bugzilla.openwatcom.org/show_bug.cgi?id=1159
Summary: Compound assignment with division or modulo produces
bogus results
Product: Open Watcom C/C++ Compiler
Version: OW 1.9
Platform: All (Generic)
OS/Version: Windows 7
Status: UNCONFIRMED
Severity: normal
Priority: --
Component: wcl386.exe
AssignedTo:
openwatco...@openwatcom.org
ReportedBy:
alexf...@gmail.com
// file: owdivbug.c
// compile with OW 1.9: wcl386 /q owdivbug.c
// this owdivbug.exe prints 3x2=6 failure messages
// compile with gcc 4.8.2: gcc owdivbug.c -o owdivbug.exe
// this owdivbug.exe exits cleanly
#include <stdio.h>
#include <stdlib.h>
int result = EXIT_SUCCESS;
unsigned testno;
void failure(void)
{
fprintf(stderr, "test %u failed\n", testno);
result = EXIT_FAILURE;
}
void test1(void)
{
unsigned short v1 = 65451;
signed short v2 = -103;
if ((v1 /= v2) != (unsigned short)(65451/-103)) failure();
if (v1 != (unsigned short)(65451/-103)) failure();
}
void test2(void)
{
signed char v1 = -77;
unsigned short v2 = 65439;
if ((v1 %= v2) != (-77%65439)) failure();
if (v1 != (-77%65439)) failure();
}
void test3(void)
{
int v1 = -105;
unsigned char v2 = 160;
if ((v1 /= (63u^v2)) != 27012372) failure();
if (v1 != 27012372) failure();
}
void (*tests[])(void) =
{
test1,
test2,
test3,
};
int main(void)
{
for (testno = 1; testno <= sizeof(tests)/sizeof(tests[0]); testno++)
tests[testno - 1]();
return result;
}
--
Configure bugmail:
http://bugzilla.openwatcom.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.