digitalmars.D.bugs - [Issue 8329] New: foreach over string with dchar as element isn't nothrow
- d-bugmail puremagic.com (31/31) Jun 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8329
- d-bugmail puremagic.com (11/30) Jun 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8329
- d-bugmail puremagic.com (11/11) Jun 30 2012 http://d.puremagic.com/issues/show_bug.cgi?id=8329
http://d.puremagic.com/issues/show_bug.cgi?id=8329 Summary: foreach over string with dchar as element isn't nothrow Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: nobody puremagic.com ReportedBy: jmdavisProg gmx.com --- Comment #0 from Jonathan M Davis <jmdavisProg gmx.com> 2012-06-30 18:31:02 PDT --- This code fails to compile: import std.stdio; void main() nothrow { foreach(dchar c; "hello world") {} } giving the error q.d(5): Error: _aApplycd1 is not nothrow q.d(3): Error: function D main 'main' is nothrow yet may throw if the dchar is removed, then it compiles just fine. Clearly, there's an issue with the apply function which implements iterating over strings as characters other than the character type of the string, since this really should be nothrow, but it's not. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8329 --- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2012-06-30 22:22:23 PDT --- (In reply to comment #0)This code fails to compile: import std.stdio; void main() nothrow { foreach(dchar c; "hello world") {} } giving the error q.d(5): Error: _aApplycd1 is not nothrow q.d(3): Error: function D main 'main' is nothrow yet may throw if the dchar is removed, then it compiles just fine. Clearly, there's an issue with the apply function which implements iterating over strings as characters other than the character type of the string, since this really should be nothrow, but it's not.I think it should not be nothrow. Iterating string(== immutable(char)[]) as a range of dchar runs decoding of UTF-8, and if given string has invalid UTF-8 sequence, it should throw UnicodeException (it's declared in core.exception). On the other hand, such a transcoding iteration should be pure and safe. It's enough worth. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8329 Jonathan M Davis <jmdavisProg gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID --- Comment #2 from Jonathan M Davis <jmdavisProg gmx.com> 2012-06-30 22:37:36 PDT --- Valid point. I forgot about invalid unicode. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2012