www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Anyone want to run this through dmc?

reply bcs <bcs example.com> writes:
http://blog.regehr.org/archives/558

That guy is working on some interesting stuff related to compiler bug
finding. It would be nice if we could get the DMx back-end into his
set of tested compilers. (BTW: what would it take to get a DMC/linux
built given there is a DMD/linux?)

I killed off my last windows box a few months bask or I'd do this my
self.

(Yes, I know this isn't exactly D related.)
Jul 12 2011
next sibling parent bcs <bcs example.com> writes:
== Quote from bcs (bcs example.com)'s article
 It would be nice if we could get the DMx back-end into his
 set of tested compilers. (BTW: what would it take to get a DMC/linux
 built given there is a DMD/linux?)
Seems he's interested (so the above is a relevant question):
 Quote from regehr:

 bcs, I’d be happy to add the Digital Mars compiler if I can do so on
 Linux. (The MSVC result in this post is from one of my more
 MS-friendly students.)
Jul 12 2011
prev sibling parent reply Trass3r <un known.com> writes:
Doing this on Windows is a nightmare.
After finally getting csmith to run, it produced code that apparently is  
invalid. (since also gcc reports errors)
The included perl script doesn't work at all.
Jul 12 2011
parent reply bcs <bcs example.com> writes:
== Quote from Trass3r (un known.com)'s article
 Doing this on Windows is a nightmare.
 After finally getting csmith to run, it produced code that
apparently is
 invalid. (since also gcc reports errors)
 The included perl script doesn't work at all.
That's why I'm wondering about building, DMC/linux. Also, my original motivation for posting was in hopes of getting the test case he listed run through DMC, but somehow that got lost in the edits. Anyone?
Jul 12 2011
parent reply bcs <bcs google.com> writes:
I broke down and installed wine:

bcs doors:~/Downloads/dmc$ cat split.cpp
#include <stdio.h>
struct S0 {
  unsigned f1 : 1;
};

struct S0 s;

int main (void) {
  int x = -3;
  int y = x >= (0, s.f1);
  printf ("%d\n", y);
  return 0;
}
bcs doors:~/Downloads/dmc$ wine dm/bin/dmc.exe split.cpp
link split,,,user32+kernel32/noi;

bcs doors:~/Downloads/dmc$ wine split.exe
1

seems DMC is broke too, but it's debatable if this test case is of
value to DMD.
Jul 12 2011
next sibling parent reply Trass3r <un known.com> writes:
 seems DMC is broke too, but it's debatable if this test case is of
 value to DMD.
Yep, is dmc's backend still updated with improvements made in dmd's backend?
Jul 13 2011
parent Don <nospam nospam.com> writes:
Trass3r wrote:
 seems DMC is broke too, but it's debatable if this test case is of
 value to DMD.
Yep, is dmc's backend still updated with improvements made in dmd's backend?
Yes. But backend bugs are very rare -- roughly 3 are reported per year, compared to 1000 per year for the front-end. About half of those bugs are caused by D-specific situations which never occur in the C compiler.
Jul 22 2011
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 7/12/2011 10:11 PM, bcs wrote:
 #include<stdio.h>
 struct S0 {
    unsigned f1 : 1;
 };

 struct S0 s;

 int main (void) {
    int x = -3;
    int y = x>= (0, s.f1);
    printf ("%d\n", y);
    return 0;
 }
 bcs doors:~/Downloads/dmc$ wine dm/bin/dmc.exe split.cpp
 link split,,,user32+kernel32/noi;

 bcs doors:~/Downloads/dmc$ wine split.exe
 1

 seems DMC is broke too, but it's debatable if this test case is of
 value to DMD.
DMC has its own bugzilla, can you post the csmith bugs there, and put csmith in the subject? That'd be cool! http://bugzilla.digitalmars.com/issues/buglist.cgi?quicksearch=.
Jul 22 2011
prev sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 7/12/2011 10:11 PM, bcs wrote:
 I broke down and installed wine:

 bcs doors:~/Downloads/dmc$ cat split.cpp
 #include<stdio.h>
 struct S0 {
    unsigned f1 : 1;
 };

 struct S0 s;

 int main (void) {
    int x = -3;
    int y = x>= (0, s.f1);
    printf ("%d\n", y);
    return 0;
 }
 bcs doors:~/Downloads/dmc$ wine dm/bin/dmc.exe split.cpp
 link split,,,user32+kernel32/noi;

 bcs doors:~/Downloads/dmc$ wine split.exe
 1

 seems DMC is broke too, but it's debatable if this test case is of
 value to DMD.
I think DMC is correct here. x >= (0, s.f1) is typed as: int >= (int, unsigned) which is: int >= unsigned which does an unsigned compare, 0xFFFFFFFD >= 1 which evaluates to: 1
Jul 22 2011
parent reply Don <nospam nospam.com> writes:
Walter Bright wrote:
 On 7/12/2011 10:11 PM, bcs wrote:
 I broke down and installed wine:

 bcs doors:~/Downloads/dmc$ cat split.cpp
 #include<stdio.h>
 struct S0 {
    unsigned f1 : 1;
 };

 struct S0 s;

 int main (void) {
    int x = -3;
    int y = x>= (0, s.f1);
    printf ("%d\n", y);
    return 0;
 }
 bcs doors:~/Downloads/dmc$ wine dm/bin/dmc.exe split.cpp
 link split,,,user32+kernel32/noi;

 bcs doors:~/Downloads/dmc$ wine split.exe
 1

 seems DMC is broke too, but it's debatable if this test case is of
 value to DMD.
I think DMC is correct here. x >= (0, s.f1) is typed as: int >= (int, unsigned) which is: int >= unsigned which does an unsigned compare, 0xFFFFFFFD >= 1 which evaluates to: 1
From a comment on that page: ------ The interpretation turns on how you interpret 6.3.1.1p2: The following may be used in an expression wherever an int or unsigned int may be used: — An object or expression with an integer type whose integer conversion rank is less than or equal to the rank of int and unsigned int. — A bit-field of type _Bool, int, signed int, or unsigned int. If an int can represent all values of the original type, the value is converted to an int; otherwise, it is converted to an unsigned int. These are called the integer promotions. All other types are unchanged by the integer promotions. ------ So the unsigned bit field should be promoted to int. And the simplified case: x >= s.f1 should definitely be a signed comparison. Makes me wonder why signed-ness of bitfields is even allowed.
Jul 25 2011
parent Walter Bright <newshound2 digitalmars.com> writes:
On 7/25/2011 3:49 PM, Don wrote:
 So the unsigned bit field should be promoted to int.
Reading further shows that there is some controversy about this. It boils down to the C spec not being clear. DMC does what other major compilers do, so my inclination is to leave it as is until the C committee decides what to do about it.
Jul 25 2011