www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11943] New: Emit warning for default initialized pointers

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11943

           Summary: Emit warning for default initialized pointers
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bugzilla digitalmars.com



18:53:23 PST ---
Consider:

class C { ... }

void foo() {
     C c;           // warning: c is default initialized to null. If that is
                    // intended, write it as C c = null;
     C d = null;    // no warning

     int* p;        // warning ...
     int* q = null; // no warning
}

Of course, this won't eliminate null pointers. But it would put a dent
in the inadvertancy of them.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 17 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11943


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yebblies gmail.com



Oh hell no.  Isn't this exactly the kind of useless false-positive warning
you're usually against?

This would be at home in a lint tool, but IMO has no place as a compiler
warning.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 17 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11943


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



I think this is a bad idea, and it doesn't solve the the intended problem,
beside having other problems. Weren't you against warnings? Instead I suggest
you to do this (in this order):
1) Go read 5 or 10 good recent research papers on this topic;
2) Go look at how 3 or 4 recently designed languages already solve this
problem;
3) Go in the D newsgroup, present your proposed solution and discuss it with
people;
4) Write a DIP, discuss it and try to remove all its corner cases and difficult
situations;
5) Try to implement it, offer it as experimental solution (with some compiler
switch? A pragma?), and collect usage opinions from people.
6) Fix and improve the design and implementation.
7) If all is OK, make it a permanent feature of the language, otherwise remove
it from the compiler.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 18 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11943




10:52:43 PST ---

 2) Go look at how 3 or 4 recently designed languages already solve this
 problem;
-- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 18 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11943




11:52:33 PST ---
 Weren't you against warnings?
Not as a path towards deprecation and eventually making it an error. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 18 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11943





 Weren't you against warnings?
Not as a path towards deprecation and eventually making it an error.
You fuss about even tiny breaking changes of my my enhancement requests, and now are you suggesting to eventually turn this into an error? int* p; I see no evidence that this whole idea will improve the situation. And how do you initialize dynamic arrays of pointers/references? auto arr = new int*[10]; I suggest to read some updated research papers on the whole topic (about F*, and other from Microsoft Research), and look at how other modern languages solve this problem. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 18 2014