Bug 5291 – ref parameter and const/immutable == hole in const system

Status
RESOLVED
Resolution
DUPLICATE
Severity
critical
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-11-29T18:07:00Z
Last change time
2011-01-26T18:27:18Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
simen.kjaras

Comments

Comment #0 by simen.kjaras — 2010-11-29T18:07:18Z
Can't believe nobody has noticed this before: void bar( ref int n ) { n++; } void main( string[] args ) { const int n = args.length * 0; assert( is( typeof( n ) == const(int) ) ); bar( n ); // Uhm... assert( n == 1 ); // WTF?!? }
Comment #1 by andrej.mitrovich — 2010-11-29T18:29:09Z
immutable bug example: bug.d: void bar( ref int n ) { n++; } void main( string[] args ) { immutable int n = args.length * 0; assert( is( typeof( n ) == const(int) ) ); bar( n ); // Uhm... assert( n == 1 ); } compiled with "dmd bug.d" core.exception.AssertError@bug(11): Assertion failure compiled with "dmd bug.d -release -O -inline" object.Error: assert(0) or HLT instruction
Comment #2 by andrej.mitrovich — 2010-11-29T18:30:13Z
(In reply to comment #1) > immutable bug example: > > bug.d: > void bar( ref int n ) > { > n++; > } > > void main( string[] args ) > { > immutable int n = args.length * 0; > assert( is( typeof( n ) == const(int) ) ); > bar( n ); // Uhm... > assert( n == 1 ); > } > > compiled with "dmd bug.d" > core.exception.AssertError@bug(11): Assertion failure > > compiled with "dmd bug.d -release -O -inline" > object.Error: assert(0) or HLT instruction My bad I forgot about the first assert. Sorry!
Comment #3 by nfxjfg — 2010-11-30T01:01:24Z
This is actually well known. See bug 2095 or bug 4251. I can't believe it hasn't been fixed yet.
Comment #4 by yebblies — 2011-01-26T18:27:18Z
*** This issue has been marked as a duplicate of issue 5493 ***