www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9565] New: Index of static array should not print literal suffix

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

           Summary: Index of static array should not print literal suffix
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          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> 2013-02-21 20:56:52 PST ---
Index type of static array is always size_t, so suffix is not only just
redundant, but also is harmful for platform independent diagnostic message.

  alias T = int[10];
  pragma(msg, T);
  // should print `int[10]` rather than `int[10u]` or `int[10LU]`.

Similar problem exists in IndexExp and SliceExp

  int[] arr;
  pragma(msg, (arr[0]).stringof);        // arr[cast(uint)0]
  pragma(msg, (arr[0..1]).stringof);     // arr[cast(uint)0..cast(uint)1]
  // should print arr[0] and arr[0..1]

But, it would need to keep "cast(...)" output for some cases

  pragma(msg, (arr[int.min]).stringof);  // arr[cast(uint)-2147483648]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 21 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565


bearophile_hugs eml.cc changed:

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


--- Comment #1 from bearophile_hugs eml.cc 2013-02-22 03:05:12 PST ---
(In reply to comment #0)

 But, it would need to keep "cast(...)" output for some cases
 
   pragma(msg, (arr[int.min]).stringof);  // arr[cast(uint)-2147483648]

I'd even like D to statically refuse indexing an array with a -2147483648 index :-) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-02-22
11:16:16 PST ---
(In reply to comment #0)
 Index type of static array is always size_t, so suffix is not only just
 redundant, but also is harmful for platform independent diagnostic message.

I think the reason it's there is to make the actual literal valid, because AFAIK you actually need to append "LU" for some big literals. But maybe we could remove the suffixes for small literals. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 22 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565



--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2013-03-01 02:35:57 PST ---
(In reply to comment #2)
 (In reply to comment #0)
 Index type of static array is always size_t, so suffix is not only just
 redundant, but also is harmful for platform independent diagnostic message.

I think the reason it's there is to make the actual literal valid, because AFAIK you actually need to append "LU" for some big literals. But maybe we could remove the suffixes for small literals.

You are right. if the dimension is in (long.max, ulong.max], "LU" suffix is necessary. (If LU is not there, "signed integer overflow" error will occur in lexer). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 01 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull


--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2013-09-03 17:30:22 PDT ---
https://github.com/D-Programming-Language/dmd/pull/2522

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565



--- Comment #5 from github-bugzilla puremagic.com 2013-09-04 07:58:50 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/5fac5f8949ae22e8d8168e8b48eff57fef052b9b
Additional fix for issue 9565

https://github.com/D-Programming-Language/phobos/commit/b79d1111e7eb7d30a566c1238d35c9fb82b0e572
Merge pull request #1544 from 9rnsr/fix9565

Additional fix for issue 9565

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 04 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565



--- Comment #6 from github-bugzilla puremagic.com 2013-09-15 00:36:45 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/d1ab5012b00c34023ed715a0c22ecb3bd8b674ff
fix Issue 9565 - Index of static array should not print literal suffix

Static array type index is always size_t, so unnecessary suffix is harmful for
platform independent diagnostic message.
(Note that: In 64bit platform, size_t is ulong, and if the value is greater
than long.max, suffix is *necessary*.)

Same problem exists in IndexExp and SliceExp printing.

https://github.com/D-Programming-Language/dmd/commit/724566600724314a27dbf7bfd63aeda12f27780d
Merge pull request #2522 from 9rnsr/fix9565

Issue 9565 - Index of static array should not print literal suffix

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 15 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED
           Severity|normal                      |enhancement


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 15 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9565



--- Comment #7 from github-bugzilla puremagic.com 2013-09-28 19:33:49 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/1c1633533435c48aac8811f41dabb4009da61bd0
Fixup for issue 9565

Remove unnecessary else block so right not it's never used.

https://github.com/D-Programming-Language/phobos/commit/d744bec6d4500d6cb6f43011beefc7765dd0e5ce
Merge pull request #1605 from 9rnsr/fix9565

Fixup for issue 9565 - cleanup of #1544

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 28 2013