digitalmars.D.bugs - [Issue 10482] New: Regression (2.063): Compiler allows constant global functions
- d-bugmail puremagic.com (27/29) Jun 26 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (16/16) Jun 27 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (10/10) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (13/13) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (13/89) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (6/6) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (7/7) Jun 30 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (14/14) Jul 02 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
- d-bugmail puremagic.com (10/17) Jul 02 2013 http://d.puremagic.com/issues/show_bug.cgi?id=10482
http://d.puremagic.com/issues/show_bug.cgi?id=10482 Summary: Regression (2.063): Compiler allows constant global functions Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: regression Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: andrej.mitrovich gmail.com 17:42:58 PDT --- ----- const int * foo(); void main() { } ----- 2.062: $ dmd test.dtest.d(3): Error: function test.foo without 'this' cannot be const/immutable2.063: $ dmd test.dI'm not sure how this happened, I remember we had a test-suite covering these. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 26 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 Henning Pohl <henning still-hidden.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |henning still-hidden.de PDT --- This behaviour is wanted, moving const after the function name will produce an error: int* foo() const; ---- Error: function main.foo without 'this' cannot be const ---- See http://d.puremagic.com/issues/show_bug.cgi?id=10150 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 27 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 bearophile_hugs eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs eml.cc See also Issue 10511 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 Dicebot <m.strashun gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |m.strashun gmail.com This is irrelevant to Issue 10511. Global const functions are still invalid, no regressions here : http://dpaste.1azy.net/a2500829 Looks like 2.062 had bug in parser and coupled leading 'const' with function type instead of return type. IMHO this is invalid / won't fix. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 09:56:33 PDT ---IMHO this is invalid / won't fix.See my comments: http://d.puremagic.com/issues/show_bug.cgi?id=10150#c4 http://d.puremagic.com/issues/show_bug.cgi?id=10150#c5 I'm reposting them here:I disagree with this change, this is extremely dangerous behavior when interfacing with C. Take a look at the following: ----- extern(C) const int *foo(); void main() { *foo() = 1; // compiles } ----- The proper definition should have been: ----- extern(C) const(int)* foo(); void main() { *foo() = 1; // fails } ----- It is very easy to make this mistake, it should not be silent, at least not for module-scoped functions. Alternatively as a compromise I suggest we at least add this check for extern(C) functions, because this is where this problem can occur very frequently.I disagree with this change, this is extremely dangerous behavior when interfacing with C. Take a look at the following: ----- extern(C) const int *foo(); void main() { *foo() = 1; // compiles } ----- The proper definition should have been: ----- extern(C) const(int)* foo(); void main() { *foo() = 1; // fails } ----- It is very easy to make this mistake, it should not be silent, at least not for module-scoped functions. Alternatively as a compromise I suggest we at least add this check for extern(C) functions, because this is where this problem can occur very frequently.Another alternative is to make the compiler smarter, and only disallow const where it's only applied to one function, for example: ----- const int * foo(); // disallowed const { int * foo(); // ok int * bar(); // ok } const: int * foo(); // ok ----- This would be for the sake of convenience, to avoid breaking existing code.-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 09:57:38 PDT --- Sorry for the duplicate paste of comment 4. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 Yeah, have figure out that it is actually no-op in prefix mode now. Still not what title claims, but is.. inconvenient. Moving in that thread. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jun 30 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482 Kenji Hara <k.hara.pg gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|regression |enhancement This is an intended change comes from issue 10150, so is not a regression. Today dmd never distinguishes prefix storage class and scopes/labeled ones. That's a design decision which sometimes talked by Walter. But also, I can agree that it is a little bug-prone behavior. So I switch this into enhancement issue. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 02 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10482This is an intended change comes from issue 10150, so is not a regression. Today dmd never distinguishes prefix storage class and scopes/labeled ones. That's a design decision which sometimes talked by Walter. But also, I can agree that it is a little bug-prone behavior. So I switch this into enhancement issue.Yep, it is not a regression but a breaking change introduces by 10150, which should not have been implemented in the first place. I wish I have noticed that pull request before it was merged. There is currently minor discussion on topic in 10150 thread. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 02 2013