www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7570] New: No true error message in one CTFE

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7570

           Summary: No true error message in one CTFE
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This may be wrong D2 code, if DMD is not able to run it at compile-time:


bool not_end(const char *s, const int n) {
    return s && s[n];
}
bool str_prefix(const char *s, const char *t, const int ns, const int nt) {
    return (s == t) || !*(t + nt) || (*(s + ns) == *(t + nt) && (str_prefix(s,
t, ns+1, nt+1)));
}
bool contains(const char *s, const char *needle, const int n=0) {
    return not_end(s, n) && (str_prefix(s, needle, n, 0) || contains(s, needle,
n+1));
}
enum int x = contains("froogler", "oogle");
void main() {}



DMD 2.059head gives no true error message, just some "called from here":

bug.d(8):        called from here: str_prefix(s,needle,n,0)
bug.d(10):        called from here: contains("froogler","oogle",0)
bug.d(8):        called from here: str_prefix(s,needle,n,0)
bug.d(10):        called from here: contains("froogler","oogle",0)
bug.d(8):        called from here: str_prefix(s,needle,n,0)
bug.d(10):        called from here: contains("froogler","oogle",0)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 24 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7570


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE, rejects-valid
                 CC|                            |yebblies gmail.com
           Platform|x86                         |All
            Version|D2                          |D1 & D2
         AssignedTo|nobody puremagic.com        |clugdbug yahoo.com.au
            Summary|No true error message in    |Missing error in ctfe for
                   |one CTFE                    |dereferencing a pointer
                   |                            |passed as a parameter
         OS/Version|Windows                     |All



The interpreter can't seem to handle '!*(t + nt)', as constfold.c's Ptr only
handles TOKaddress + TOKint64, and it resolves to TOKvar + TOKint64, and
PtrExp::interpret doesn't handle the case where Ptr fails.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7570




Reduced test case:
========================================
bool contains(const char *s) {
    return *(s + 0) == 'a';
}
static assert(!contains("froogler"));

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 02 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7570




Now fails with:
DMD v2.062 DEBUG
testx.d(4):        called from here: contains("froogler")
testx.d(4): Error: static assert  (!contains("froogler")) is not evaluatable at
compile time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 16 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7570


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|diagnostic                  |



I remove the diagnostic tag because the diagnostic now seems acceptable.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 16 2013