Thread overview | ||||||
---|---|---|---|---|---|---|
|
September 21, 2012 [Issue 8703] New: Disabling default ctor does not forbid default construction | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=8703 Summary: Disabling default ctor does not forbid default construction Product: D Version: D2 Platform: All OS/Version: All Status: NEW Keywords: accepts-invalid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: k.hara.pg@gmail.com --- Comment #0 from Kenji Hara <k.hara.pg@gmail.com> 2012-09-21 05:49:56 PDT --- This code should fail to compile, but doesn't. struct S { @disable this(); } void main() { auto s = S(); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 21, 2012 [Issue 8703] Disabling default ctor does not forbid default construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=8703 Simen Kjaeraas <simen.kjaras@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |simen.kjaras@gmail.com Resolution| |DUPLICATE --- Comment #1 from Simen Kjaeraas <simen.kjaras@gmail.com> 2012-09-21 06:06:56 PDT --- *** This issue has been marked as a duplicate of issue 7021 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 21, 2012 [Issue 8703] Disabling default ctor does not forbid default construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=8703 Maxim Fomin <maxim@maxim-fomin.ru> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |maxim@maxim-fomin.ru --- Comment #2 from Maxim Fomin <maxim@maxim-fomin.ru> 2012-09-21 09:05:26 PDT --- (In reply to comment #0) > This code should fail to compile, but doesn't. > > struct S > { > @disable this(); > } > void main() > { > auto s = S(); > } Actually it is consistent with current D implementation (whether you like it or not). The root of this issue is that S() is neither "implicit constructor" nor struct literal - it is default initializer for struct. Currently structs can be initialized at runtime by four methods: default initializer, struct literal, constructor or opCall. In the example you block ctor but not default initializer. This is why S() works, but S.__ctor() as expected doesn't. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
September 22, 2012 [Issue 8703] Disabling default ctor does not forbid default construction | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kenji Hara | http://d.puremagic.com/issues/show_bug.cgi?id=8703 --- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-09-21 18:57:04 PDT --- (In reply to comment #2) > (In reply to comment #0) > > This code should fail to compile, but doesn't. > > > > struct S > > { > > @disable this(); > > } > > void main() > > { > > auto s = S(); > > } > > Actually it is consistent with current D implementation (whether you like it or not). The root of this issue is that S() is neither "implicit constructor" nor struct literal - it is default initializer for struct. Currently structs can be initialized at runtime by four methods: default initializer, struct literal, constructor or opCall. In the example you block ctor but not default initializer. This is why S() works, but S.__ctor() as expected doesn't. Yes, that's my point. In current S() represents default initializer, but I think it is invalid, because S has a constructor efen if it has no parameter and @disable. -- 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