View mode: basic / threaded / horizontal-split · Log in · Help
February 24, 2012
[Issue 7570] New: No true error message in one CTFE
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


--- Comment #0 from bearophile_hugs@eml.cc 2012-02-24 05:05:19 PST ---
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: -------
February 24, 2012
[Issue 7570] Missing error in ctfe for dereferencing a pointer passed as a parameter
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


--- Comment #1 from yebblies <yebblies@gmail.com> 2012-02-25 00:43:47 EST ---
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: -------
March 02, 2012
[Issue 7570] Missing error in ctfe for dereferencing a pointer passed as a parameter
http://d.puremagic.com/issues/show_bug.cgi?id=7570



--- Comment #2 from Don <clugdbug@yahoo.com.au> 2012-03-02 06:20:59 PST ---
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: -------
January 16, 2013
[Issue 7570] Missing error in ctfe for dereferencing a pointer passed as a parameter
http://d.puremagic.com/issues/show_bug.cgi?id=7570



--- Comment #3 from yebblies <yebblies@gmail.com> 2013-01-17 02:11:46 EST ---
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: -------
January 16, 2013
[Issue 7570] Missing error in ctfe for dereferencing a pointer passed as a parameter
http://d.puremagic.com/issues/show_bug.cgi?id=7570


bearophile_hugs@eml.cc changed:

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


--- Comment #4 from bearophile_hugs@eml.cc 2013-01-16 10:08:45 PST ---
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: -------
Top | Discussion index | About this forum | D home