www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 953] New: Multiple C style declarations of same type cannot be in one statement

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

           Summary: Multiple C style declarations of same type cannot be in
                    one statement
           Product: D
           Version: 1.005
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: minor
          Priority: P3
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: deewiant gmail.com


int foo[2], bar[2];

The above fails with the error message "multiple declarations must have the
same type, not int[2] and int[2]" which makes no sense. int[2] is the same type
as int[2].


-- 
Feb 12 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=953


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




------- Comment #1 from bugzilla digitalmars.com  2007-03-20 03:41 -------
This is by design. The declaration should be:

int[2] foo, bar;

More than one C-style declaration in the same line is not allowed.


-- 
Mar 20 2007
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=953


deewiant gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|minor                       |trivial
             Status|RESOLVED                    |REOPENED
           Keywords|rejects-valid               |diagnostic
           Priority|P3                          |P4
         Resolution|INVALID                     |




------- Comment #2 from deewiant gmail.com  2007-03-20 04:10 -------
Then it's a problem with the error message, which should say that, instead of
its current nonsense.


-- 
Mar 20 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=953


Witold Baryluk <baryluk smp.if.uj.edu.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |baryluk smp.if.uj.edu.pl




--- Comment #3 from Witold Baryluk <baryluk smp.if.uj.edu.pl>  2009-08-10
05:10:34 PDT ---
Hi, i just tried in DMD 1.043

int a[8], c[8];

and given me this nonsensical error. I know this is redudant, but is there to
allow C style declarations. I just switch many times from C to D, and sometimes
forgot where am I.

In declarations.html we read:
"In a declaration declaring multiple symbols, all the declarations must be of
the same type:
 int x,y;    // x and y are ints
 int* x,y;    // x and y are pointers to ints
 int x,*y;    // error, multiple types
 int[] x,y;    // x and y are arrays of ints
 int x[],y;    // error, multiple types
"

I was all my life (actually life when i use D, so about 3 years) thinking this
means, that:

int[8] a,b,c;

is equivalent of

int a[8], b[8], c[8];

how about adding to spec example this entries:
 int[2] x,y;     // x and y are static arrays of ints
 int x[2],y;     // error, multiple types
 int x[2],y[2];  // error, multiple types
 int x[2],y[3];  // error, multiple types

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 10 2009