www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - DMD source violates c++11 standards.

reply "Hans W. Uhlig" <huhlig gmail.com> writes:
This also makes compiling LDC with clang rather difficult

[  1%] Building CXX object CMakeFiles/LDCShared.dir/dmd2/func.c.o
/root/llvm/src/ldc/dmd2/func.c:540:18: error: case value 
evaluates to -2, which cannot be narrowed to type 'size_t' (aka 
'unsigned long') [-Wc++11-narrowing]
             case -2:    // can't determine because of fwd refs
                  ^
/root/llvm/src/ldc/dmd2/func.c:503:18: error: case value 
evaluates to -1, which cannot be narrowed to type 'size_t' (aka 
'unsigned long') [-Wc++11-narrowing]
             case -1:
                  ^
/root/llvm/src/ldc/dmd2/func.c:632:22: error: case value 
evaluates to -2, which cannot be narrowed to type 'size_t' (aka 
'unsigned long') [-Wc++11-narrowing]
                 case -2:
                      ^
/root/llvm/src/ldc/dmd2/func.c:629:22: error: case value 
evaluates to -1, which cannot be narrowed to type 'size_t' (aka 
'unsigned long') [-Wc++11-narrowing]
                 case -1:
May 27 2013
next sibling parent reply "Daniel Murphy" <yebblies nospamgmail.com> writes:
"Hans W. Uhlig" <huhlig gmail.com> wrote in message 
news:idtvbddofuxwpsbtowsj forum.dlang.org...
 This also makes compiling LDC with clang rather difficult

DMD is not written in C++11. Turning of the C++11 warnings in clang will fix this problem.
May 27 2013
parent Walter Bright <newshound2 digitalmars.com> writes:
On 5/27/2013 4:47 PM, Daniel Murphy wrote:
 "Hans W. Uhlig" <huhlig gmail.com> wrote in message
 news:idtvbddofuxwpsbtowsj forum.dlang.org...
 This also makes compiling LDC with clang rather difficult

DMD is not written in C++11. Turning of the C++11 warnings in clang will fix this problem.

Also, you can submit a bugzilla entry for it, or even a pull request. There's no reason for such code in DMD to remain.
May 27 2013
prev sibling next sibling parent "Borden" <2013 bordenrhodes.com> writes:
On Tuesday, 28 May 2013 at 00:12:57 UTC, Walter Bright wrote:
 On 5/27/2013 4:47 PM, Daniel Murphy wrote:
 "Hans W. Uhlig" <huhlig gmail.com> wrote in message
 news:idtvbddofuxwpsbtowsj forum.dlang.org...
 This also makes compiling LDC with clang rather difficult

DMD is not written in C++11. Turning of the C++11 warnings in clang will fix this problem.

Also, you can submit a bugzilla entry for it, or even a pull request. There's no reason for such code in DMD to remain.

I was thinking about that: surely D's mature enough that dmd can be written in D?
May 27 2013
prev sibling next sibling parent Ziad Hatahet <hatahet gmail.com> writes:
--047d7b603c78da741604ddbc1b08
Content-Type: text/plain; charset=ISO-8859-1

On Mon, May 27, 2013 at 4:47 PM, Daniel Murphy <yebblies nospamgmail.com>wrote:

 DMD is not written in C++11.  Turning of the C++11 warnings in clang will
 fix this problem

True, but could it not be the case that, since there might be stricter type checking included, certain errors might show up? Like the example above, where a switch is being done on an unsigned type, and negative cases are being handled. -- Ziad --047d7b603c78da741604ddbc1b08 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <br><br><div class=3D"gmail_quote">On Mon, May 27, 2013 at 4:47 PM, Daniel = Murphy <span dir=3D"ltr">&lt;<a href=3D"mailto:yebblies nospamgmail.com" ta= rget=3D"_blank">yebblies nospamgmail.com</a>&gt;</span> wrote:<br><blockquo= te class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc so= lid;padding-left:1ex"> DMD is not written in C++11. =A0Turning of the C++11 warnings in clang will= <br> fix this problem</blockquote><div><br>True, but could it not be the case th= at, since there might be stricter type checking included, certain errors mi= ght show up? Like the example above, where a switch is being done on an uns= igned type, and negative cases are being handled.<br> <br clear=3D"all"><div>--<br>Ziad</div>=A0 <br></div></div> --047d7b603c78da741604ddbc1b08--
May 27 2013
prev sibling next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Tuesday, May 28, 2013 02:15:39 Borden wrote:
 I was thinking about that: surely D's mature enough that dmd can
 be written in D?

Work is being done to convert it to D, but there's a fair bit of work to do for it to happen (like improving what extern(C++) can do so that it can better integrate with the various backends). - Jonathan M Davis
May 27 2013
prev sibling next sibling parent "Hans W. Uhlig" <huhlig gmail.com> writes:
Prepping a patch for dmd to correct some of the C++11 Correctness 
issues.

I came across this set and am a bit hesitant to change it without 
knowing side effects.

/home/huhlig/Temp/d/ldc/dmd2/struct.c:239:14: error: case value 
evaluates to -1, which cannot be narrowed to type 'structalign_t' 
(aka 'unsigned int')
       [-Wc++11-narrowing]
         case STRUCTALIGN_DEFAULT:
              ^
/home/huhlig/Temp/d/ldc/dmd2/mars.h:308:29: note: expanded from 
macro 'STRUCTALIGN_DEFAULT'
#define STRUCTALIGN_DEFAULT ~0  // magic value means "match 
whatever the underlying C compiler does"

void AggregateDeclaration::alignmember(
         structalign_t alignment,   // struct alignment that is in 
effect
         unsigned size,             // alignment requirement of 
field
         unsigned *poffset)
{
     //printf("alignment = %d, size = %d, offset = 
%d\n",alignment,size,offset);
     switch (alignment)
     {
         case 1:
             // No alignment
             break;

         case STRUCTALIGN_DEFAULT:
         {   /* Must match what the corresponding C compiler's 
default
              * alignment behavior is.
              */
             assert(size != 3);
             unsigned sa = (size == 0 || 8 < size) ? 8 : size;
             *poffset = (*poffset + sa - 1) & ~(sa - 1);
             break;
         }

         default:
             // Align on alignment boundary, which must be a 
positive power of 2
             assert(alignment > 0 && !(alignment & (alignment - 
1)));
             *poffset = (*poffset + alignment - 1) & ~(alignment - 
1);
             break;
     }
}
May 28 2013
prev sibling next sibling parent "Maxim Fomin" <maxim maxim-fomin.ru> writes:
On Monday, 27 May 2013 at 23:25:37 UTC, Hans W. Uhlig wrote:
 This also makes compiling LDC with clang rather difficult

 [  1%] Building CXX object 
 CMakeFiles/LDCShared.dir/dmd2/func.c.o
 /root/llvm/src/ldc/dmd2/func.c:540:18: error: case value 
 evaluates to -2, which cannot be narrowed to type 'size_t' (aka 
 'unsigned long') [-Wc++11-narrowing]
             case -2:    // can't determine because of fwd refs
                  ^
 /root/llvm/src/ldc/dmd2/func.c:503:18: error: case value 
 evaluates to -1, which cannot be narrowed to type 'size_t' (aka 
 'unsigned long') [-Wc++11-narrowing]
             case -1:
                  ^
 /root/llvm/src/ldc/dmd2/func.c:632:22: error: case value 
 evaluates to -2, which cannot be narrowed to type 'size_t' (aka 
 'unsigned long') [-Wc++11-narrowing]
                 case -2:
                      ^
 /root/llvm/src/ldc/dmd2/func.c:629:22: error: case value 
 evaluates to -1, which cannot be narrowed to type 'size_t' (aka 
 'unsigned long') [-Wc++11-narrowing]
                 case -1:

There were discussions raised in the past about dmd source compile warnings which are generated by enabling some warning options. Depending on which switches are turned on, compiler can produce from 100 up to 10_000 warnings. Most of them are useless since they do not perform flow analysis (for example, those complains about variables may being not initialized which ignore assertions) or are issued in dirty backend code. It is extremly unlikely to extract something worth fixing from such large amount of messages. Dmd sources are at everyday look of dozen developers, so there is low probability to get from warnings something useful which solves potential problem. I use conservative number of warning switches which produces two warnings in current dmd git sources - one about obsolete cast from string type to char*, and the second about ignoring __cdecl attribute. I don't bother to fix them.
May 28 2013
prev sibling next sibling parent "Hans W. Uhlig" <huhlig gmail.com> writes:
On Tuesday, 28 May 2013 at 19:33:08 UTC, Maxim Fomin wrote:
 On Monday, 27 May 2013 at 23:25:37 UTC, Hans W. Uhlig wrote:
 This also makes compiling LDC with clang rather difficult

 [  1%] Building CXX object 
 CMakeFiles/LDCShared.dir/dmd2/func.c.o
 /root/llvm/src/ldc/dmd2/func.c:540:18: error: case value 
 evaluates to -2, which cannot be narrowed to type 'size_t' 
 (aka 'unsigned long') [-Wc++11-narrowing]
            case -2:    // can't determine because of fwd refs
                 ^
 /root/llvm/src/ldc/dmd2/func.c:503:18: error: case value 
 evaluates to -1, which cannot be narrowed to type 'size_t' 
 (aka 'unsigned long') [-Wc++11-narrowing]
            case -1:
                 ^
 /root/llvm/src/ldc/dmd2/func.c:632:22: error: case value 
 evaluates to -2, which cannot be narrowed to type 'size_t' 
 (aka 'unsigned long') [-Wc++11-narrowing]
                case -2:
                     ^
 /root/llvm/src/ldc/dmd2/func.c:629:22: error: case value 
 evaluates to -1, which cannot be narrowed to type 'size_t' 
 (aka 'unsigned long') [-Wc++11-narrowing]
                case -1:

There were discussions raised in the past about dmd source compile warnings which are generated by enabling some warning options. Depending on which switches are turned on, compiler can produce from 100 up to 10_000 warnings. Most of them are useless since they do not perform flow analysis (for example, those complains about variables may being not initialized which ignore assertions) or are issued in dirty backend code. It is extremly unlikely to extract something worth fixing from such large amount of messages. Dmd sources are at everyday look of dozen developers, so there is low probability to get from warnings something useful which solves potential problem. I use conservative number of warning switches which produces two warnings in current dmd git sources - one about obsolete cast from string type to char*, and the second about ignoring __cdecl attribute. I don't bother to fix them.

These are just from the standard set of clang switched while trying to compile LDC.
May 28 2013
prev sibling next sibling parent "David Nadlinger" <see klickverbot.at> writes:
On Tuesday, 28 May 2013 at 19:56:40 UTC, Hans W. Uhlig wrote:
 These are just from the standard set of clang switched while 
 trying to compile LDC.

More precisely, they are pulled in from the LLVM compiler flags (llvm-config --cxxflags) if LLVM was compiled with --enable-cxx11. David
May 28 2013
prev sibling next sibling parent "David Nadlinger" <see klickverbot.at> writes:
On Tuesday, 28 May 2013 at 21:16:44 UTC, David Nadlinger wrote:
 More precisely, they are pulled in from the LLVM compiler flags
 (llvm-config --cxxflags) if LLVM was compiled with 
 --enable-cxx11.

(i.e. the C++11 mode switch) I'd much prefer for this one to be resolved in the DMD source instead of as a hack on the LDC side, as there really isn't much reason not to. David
May 28 2013
prev sibling parent "Hans W. Uhlig" <huhlig gmail.com> writes:
On Tuesday, 28 May 2013 at 21:21:57 UTC, David Nadlinger wrote:
 On Tuesday, 28 May 2013 at 21:16:44 UTC, David Nadlinger wrote:
 More precisely, they are pulled in from the LLVM compiler flags
 (llvm-config --cxxflags) if LLVM was compiled with 
 --enable-cxx11.

(i.e. the C++11 mode switch) I'd much prefer for this one to be resolved in the DMD source instead of as a hack on the LDC side, as there really isn't much reason not to. David

There is one Error on the LDC Side. dmd2/mars.c:106: --- llvm_version = "LLVM "LDC_LLVM_VERSION_STRING; +++ llvm_version = "LLVM " LDC_LLVM_VERSION_STRING;
May 28 2013