Thread overview
[Issue 4197] New: __error iso assert failure in struct function in/out statement
May 16, 2010
strtr@despam.it
May 16, 2010
strtr@despam.it
Apr 28, 2011
Don
[Issue 4197] ICE(glue.c): error in forward-referenced in/out contract
Sep 14, 2011
Walter Bright
Sep 15, 2011
Walter Bright
May 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4197

           Summary: __error iso assert failure in struct function in/out
                    statement
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: strtr@despam.it


--- Comment #0 from strtr@despam.it 2010-05-16 04:20:19 PDT ---
module main;

const S S1 = S();

struct S
{
  static S func( S s_ )
  in{ assert(false,random); }
  out(result){ assert(false,random); }
  body{ return s_; }

  const S S2 = func(S());
}
void main(){}
--
main.d(8): Error: __error <---# should be assert failure #
main.d(12): Error: cannot evaluate func((S())) at compile time

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4197


Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |Justin.SpahrSummers@gmail.c
                   |                            |om


--- Comment #1 from Justin Spahr-Summers <Justin.SpahrSummers@gmail.com> 2010-05-16 12:48:17 CDT ---
(In reply to comment #0)
> module main;
> 
> const S S1 = S();
> 
> struct S
> {
>   static S func( S s_ )
>   in{ assert(false,random); }
>   out(result){ assert(false,random); }
>   body{ return s_; }
> 
>   const S S2 = func(S());
> }
> void main(){}
> --
> main.d(8): Error: __error <---# should be assert failure #
> main.d(12): Error: cannot evaluate func((S())) at compile time

The second argument to assert() - if present - is supposed to be a string describing the condition. The error message without the second parameter or with a string there instead is correct.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4197


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #2 from bearophile_hugs@eml.cc 2010-05-16 11:03:13 PDT ---
This can be a simplified version of the same problem:


enum Foo F1 = Foo();
struct Foo {
    const Foo F2 = func();
}
Foo func() {
    assert(false, random);
    return Foo();
}
void main() {}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 16, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4197



--- Comment #3 from strtr@despam.it 2010-05-16 14:11:22 PDT ---
(In reply to comment #1)
> 
> The second argument to assert() - if present - is supposed to be a string describing the condition. The error message without the second parameter or with a string there instead is correct.

I was expecting something like :
Error: cannot implicitly cast "random" of type unknown to string
Or
Error: "random" not defined

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 28, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4197


Don <clugdbug@yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
                 CC|                            |clugdbug@yahoo.com.au
            Version|unspecified                 |D1 & D2
         OS/Version|Windows                     |All
           Severity|normal                      |major


--- Comment #4 from Don <clugdbug@yahoo.com.au> 2011-04-28 13:12:33 PDT ---
Original title was:
"__error iso assert failure in struct function in/out statement"

A reduced test case shows it is a very general ICE.
*Any* error inside an in() or out() contract in a function that is has its
semantic run through CTFE, has all errors gagged. This can result in a cryptic
error message (as in the original test case), or an ICE. This one is
ICE(glue.c), but I've also seen ICE(toir.c). It fails on both D1 and D2.

const Bug4197 s4197 = Bug4197();

int func4197()
in { undefined; }
body { return 0; }

struct Bug4197 {
  static const int S2 = func4197();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 14, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4197


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-09-14 00:46:13 PDT ---
D2 fix: https://github.com/D-Programming-Language/dmd/commit/0a927f258e89f92f280c0e855a93ceb05e34a260

Partial D1 fix: https://github.com/D-Programming-Language/dmd/commit/31d6751de3a877c72055a2096a9a9c4a9a25ec9b

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 15, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4197


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2011-09-15 11:23:10 PDT ---
D1 fix: https://github.com/D-Programming-Language/dmd/commit/23846aca52ebd21efab36ff32924c5a6cc17c4c0

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