[Issue 13229] New: RangeError in inlined function prints wrong module name (but right line)

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Jul 30 15:07:01 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=13229

          Issue ID: 13229
           Summary: RangeError in inlined function prints wrong module
                    name (but right line)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: gassa at mail.ru

When a range violation occurs in an inlined function, the error message
mentions the module which calls that function, not the module where it is
defined.  However, the line number corresponds to the file where the function
is defined.

As this points to a wrong line of the source, the error can be very confusing
the first time you encounter it.  It surely looks like "debug capabilities
broken".

-----caller.d-----
module caller;
import other;

// lines 3-5 contain no code

void main () {
    fun (2);
}
-----

-----other.d-----
module other;
int [2] x;
void fun (int i) {
    x[i]++;
}
-----

When we run "dmd caller.d other.d", we get the correct message:
core.exception.RangeError at other.d(4): Range violation

However, add -inline, as in "dmd -inline caller.d other.d", and we see the
error:
core.exception.RangeError at caller.d(4): Range violation

As you can see, line 4 of caller.d contains only a comment and so can not
generate any errors.

This is reproducible for me on DMD 2.065.0 and DMD 2.066.0-b6 on Win32 and
Win64.

--


More information about the Digitalmars-d-bugs mailing list