[Issue 4908] New: Compile-time use of empty() in Tuple failed depending on order of compilation

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Sep 21 12:26:03 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=4908

           Summary: Compile-time use of empty() in Tuple failed depending
                    on order of compilation
           Product: D
           Version: D2
          Platform: Other
               URL: http://svn.dsource.org/projects/phobos/trunk@2022
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: rsinfu at gmail.com


--- Comment #0 from Shin Fujishiro <rsinfu at gmail.com> 2010-09-21 12:25:25 PDT ---
I have no reduced test case yet.

Unzip the dmd 2.049 release. Add the following lines to std/typecons.d:
--------------------
  struct Tuple(T...)
  {
+     static string test()
+     {
+         enum s = "";
+         return s.empty ? ";" : ";";   // (316)
+     }
+     mixin(test());                    // (318)
  public:
--------------------

Then, compiling certain modules fails depending on the order of compilation:
--------------------
% dmd -c std/string std/concurrency
std/typecons.d(316): Error: cannot evaluate empty("") at compile time
std/typecons.d(318): Error: cannot evaluate test() at compile time
std/typecons.d(318): Error: argument to mixin must be a string, not (test())
% dmd -c std/concurrency std/string
% _
--------------------

The error didn't occur if I modified std.string.indexOf() as follows:
--------------------
  sizediff_t
  indexOf(Char1, Char2)(in Char1[] s, in Char2[] sub,
          CaseSensitive cs = CaseSensitive.yes)
  {
      if (cs == CaseSensitive.yes)
      {
          static if (Char1.sizeof == Char2.sizeof)
          {
-             immutable result = s.length - std.algorithm.find(s, sub).length;
+             immutable result = 0;
              return result == s.length ? -1 : result;
--------------------

This bug is no longer triggered in phobos since changeset 2032.
 http://svn.dsource.org/projects/phobos/trunk@2032

-- 
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