Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 4 - reverse allowed on string (gdc 4.6.3 !)
Summary: reverse allowed on string (gdc 4.6.3 !)
Status: RESOLVED WORKSFORME
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: development
Hardware: x86 Linux
: --- normal
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2012-08-12 21:31 CEST by Philippe Quesnel
Modified: 2012-08-22 01:21 CEST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Quesnel 2012-08-12 21:31:09 CEST
(Note that I don't have access to 4.7.x or 4.8.x on Ubuntu, this might not apply anymore ! sorry if it is the case)

gdc (Ubuntu/Linaro 4.6.3-1ubuntu1) 4.6.3
DMD32 D Compiler v2.059

GDC allows this:
(it will crash on execution)

void main() {
    string str = "allo";
    str.reverse;
    str.sort;
}

But dmd will catch the error at compile time:

dmd testStringReverse.d 
  testStringReverse.d(4): Error: can only reverse a mutable array
  testStringReverse.d(5): Error: can only sort a mutable array
Comment 1 Johannes Pfau 2012-08-21 19:21:37 CEST
This correctly prints the error at compile time with
gdc commit 9bcc0b7159 (4.7 branch)
gcc 4.7.1 (on ARM / raspberry pi, shouldn't matter)
dmd frontend 2.059

Please reopen this bug if it still occurs for you with the latest version of gdc.

gdc hello.d -o hello
hello.d:5: Error: can only reverse a mutable array
hello.d:6: Error: can only sort a mutable array
Comment 2 Philippe Quesnel 2012-08-22 01:21:32 CEST
ok, good.
I'll try it out to be sure when I can get my hands on the newest version
thx