[Mono-bugs] [Bug 570272] New: out parameter set with ternary ?: or ?? operator in generic function with 'struct' parameter constraint generates invalid code
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Jan 13 06:18:24 EST 2010
http://bugzilla.novell.com/show_bug.cgi?id=570272
http://bugzilla.novell.com/show_bug.cgi?id=570272#c0
Summary: out parameter set with ternary ?: or ?? operator in
generic function with 'struct' parameter constraint
generates invalid code
Classification: Mono
Product: Mono: Compilers
Version: 2.4.x
Platform: x86
OS/Version: Ubuntu
Status: NEW
Severity: Major
Priority: P5 - None
Component: C#
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: halfflat at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.6)
Gecko/20091215 Ubuntu/9.10 (karmic) Firefox/3.5.6
The following sample C# source, when compiled with gmcs [version 2.4.2.3
(Debian 2.4.2.3+dfsg-2] generates code which, when run with mono, raises an
Invalid IL System.InvalidProgramException.
class Q {
static void bar<T>(out T t) where T: struct {
t=true?new T():new T();
}
public static void Main(string[] args) {
int d=0;
bar(out d);
}
}
Similarly, when the ?? operator is used, the same exception is raised upon
execution:
// also fails:
static void bar<T>(out T t) where T: struct {
T? u=null;
t=u??new T();
}
However, the issue does not occur if the constraint is "where T: new()" instead
of "where T: struct":
// executes correctly:
static void bar<T>(out T t) where T: new() {
t=true?new T():new T();
}
Reproducible: Always
Steps to Reproduce:
1. The sample code above is compiled with gmcs, with or without optimization:
gmcs q.cs
2. The resulting .exe is executed:
mono q.exe
Actual Results:
On execution, mono reports:
Unhandled Exception: System.InvalidProgramException: Invalid IL code in
Q:bar<int> (int&): IL_002b: ret
at Q.Main (System.String[] args) [0x00000]
Expected Results:
No exception should be raised, and the correct program semantics should be
respected.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list