[Issue 4303] New: __traits(compiles) returns wrong result when used	recursively
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Jun 13 03:16:52 PDT 2010
    
    
  
http://d.puremagic.com/issues/show_bug.cgi?id=4303
           Summary: __traits(compiles) returns wrong result when used
                    recursively
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: patch, wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: r.sagitario at gmx.de
--- Comment #0 from Rainer Schuetze <r.sagitario at gmx.de> 2010-06-13 03:16:47 PDT ---
compiling this code:
///
template foo()
if (__traits(compiles,undefined))
{
    enum foo = false;
}
template foo()
if (true)
{
    enum foo = true;
}
pragma(msg,__traits(compiles,foo!()));
const bool bar = foo!();
/////
compiles, but outputs:
false
This is caused by __traits(compiles) not restoring the global error count in
recursive calls (more specifically: when the error output is gagged before
evaluating __traits).
Here's the patch:
Index: traits.c
===================================================================
--- traits.c    (revision 532)
+++ traits.c    (working copy)
@@ -397,8 +397,8 @@
             global.gag--;
             if (errors != global.errors)
-            {   if (global.gag == 0)
-                    global.errors = errors;
+            {
+                global.errors = errors;
                 goto Lfalse;
             }
         }
Issue 3448 seems similar, but this patch does not help there.
-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
    
    
More information about the Digitalmars-d-bugs
mailing list