Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
November 02, 2012 [Issue 8940] New: Able to modify const/immutable with passing to a templated function by `ref` | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8940 Summary: Able to modify const/immutable with passing to a templated function by `ref` Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: major Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: verylonglogin.reg@gmail.com --- Comment #0 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-11-02 18:17:31 MSK --- --- const int n; // or `immutable` static this() { n = 3; } void f(T)(ref int val) { assert(val == 3); ++val; } static assert(!__traits(compiles, f!void(n))); // fails --- As a result of the fact `f!void(n)` compiles: --- void main() { assert(n == 3); f!void(n); assert(n == 3); // may pass as compiler caches comparison result assert(n != 4); // may pass but likely will fail } --- This also leads to ability to modify const/immutable data accidentally because of incorrect overload selection: --- void g(A...)(A args) { } void g(A...)(ref A args) { assert(0); } void main() { g(1); // ok g(n); // triggers `assert(0)` } --- -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 02, 2012 [Issue 8940] Able to modify const/immutable with passing to a templated function by `ref` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=8940 --- Comment #1 from Denis Shelomovskij <verylonglogin.reg@gmail.com> 2012-11-02 18:22:48 MSK --- May be connected with Issue 8939 - ICE on passing by ref statically initialized const/immutable variable -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 03, 2012 [Issue 8940] Able to modify const/immutable with passing to a templated function by `ref` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=8940 --- Comment #2 from github-bugzilla@puremagic.com 2012-11-03 05:09:50 PDT --- Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/02c301feaafebe754a5298b60394921e32938148 Supplemental fix for Issue 8940 - Able to modify const/immutable with passing to a templated function by `ref` splitUnitsFromHNSecs accepts ref long, so it should not be called with immutable long. But' it has been accidentally accepted by issue 8940. https://github.com/D-Programming-Language/phobos/commit/941b46a0cc12ba6f5633c86f06f3acf3fd448e72 Merge pull request #921 from 9rnsr/fix8940 Supplemental fix for Issue 8940 - Able to modify const/immutable with passing to a templated function by `ref` -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 03, 2012 [Issue 8940] Able to modify const/immutable with passing to a templated function by `ref` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=8940 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-11-03 05:17:39 PDT --- https://github.com/D-Programming-Language/dmd/pull/1252 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 10, 2012 [Issue 8940] Able to modify const/immutable with passing to a templated function by `ref` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=8940 --- Comment #4 from github-bugzilla@puremagic.com 2012-11-10 11:22:42 PST --- Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/33a4b46947067defa5800badf5e9ff2c500320e7 fix Issue 8940 - Able to modify const/immutable with passing to a templated function by `ref` -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
November 11, 2012 [Issue 8940] Able to modify const/immutable with passing to a templated function by `ref` | ||||
---|---|---|---|---|
| ||||
Posted in reply to Denis Shelomovskij | http://d.puremagic.com/issues/show_bug.cgi?id=8940 Kenji Hara <k.hara.pg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation