Thread overview
GDC specific bugs
Dec 11, 2004
Thomas Kuehne
Dec 11, 2004
John Reimer
Dec 12, 2004
Thomas Kuehne
[patch] ";;" WAS: Re: GDC specific bugs
Dec 12, 2004
Thomas Kuehne
Dec 13, 2004
John Reimer
Dec 13, 2004
J C Calvarese
Dec 14, 2004
John Reimer
December 11, 2004
http://svn.kuehne.cn/dstress/run/break_03.d http://svn.kuehne.cn/dstress/run/break_04.d http://svn.kuehne.cn/dstress/run/break_05.d http://svn.kuehne.cn/dstress/nocompile/command_line_deprecated_02.d http://svn.kuehne.cn/dstress/run/delegate_04.d http://svn.kuehne.cn/dstress/nocompile/delegate_05.d http://svn.kuehne.cn/dstress/run/delegate_12.d http://svn.kuehne.cn/dstress/run/enum_07.d http://svn.kuehne.cn/dstress/run/enum_08.d http://svn.kuehne.cn/dstress/run/enum_09.d http://svn.kuehne.cn/dstress/complex/linking/ (linking_01) http://svn.kuehne.cn/dstress/nocompile/static_08.d


December 11, 2004
Thomas Kuehne wrote:
> http://svn.kuehne.cn/dstress/run/break_03.d
> http://svn.kuehne.cn/dstress/run/break_04.d
> http://svn.kuehne.cn/dstress/run/break_05.d
> http://svn.kuehne.cn/dstress/nocompile/command_line_deprecated_02.d
> http://svn.kuehne.cn/dstress/run/delegate_04.d
> http://svn.kuehne.cn/dstress/nocompile/delegate_05.d
> http://svn.kuehne.cn/dstress/run/delegate_12.d
> http://svn.kuehne.cn/dstress/run/enum_07.d
> http://svn.kuehne.cn/dstress/run/enum_08.d
> http://svn.kuehne.cn/dstress/run/enum_09.d
> http://svn.kuehne.cn/dstress/complex/linking/ (linking_01)
> http://svn.kuehne.cn/dstress/nocompile/static_08.d
> 
> 

For the "enum" stress tests, I notice that a semicolon is used to end the enum declaration.  The D standard declares them without a semicolon appended.  Would removing the semicolon change the stress test results?

- John
December 12, 2004
John Reimer schrieb:
> Thomas Kuehne wrote:
> > http://svn.kuehne.cn/dstress/run/break_03.d http://svn.kuehne.cn/dstress/run/break_04.d http://svn.kuehne.cn/dstress/run/break_05.d http://svn.kuehne.cn/dstress/nocompile/command_line_deprecated_02.d http://svn.kuehne.cn/dstress/run/delegate_04.d http://svn.kuehne.cn/dstress/nocompile/delegate_05.d http://svn.kuehne.cn/dstress/run/delegate_12.d http://svn.kuehne.cn/dstress/run/enum_07.d http://svn.kuehne.cn/dstress/run/enum_08.d http://svn.kuehne.cn/dstress/run/enum_09.d http://svn.kuehne.cn/dstress/complex/linking/ (linking_01) http://svn.kuehne.cn/dstress/nocompile/static_08.d

> For the "enum" stress tests, I notice that a semicolon is used to end the enum declaration.  The D standard declares them without a semicolon appended.  Would removing the semicolon change the stress test results?

Thanks, I removed the semicolon. The change had no impact.

Thomas


December 12, 2004
Thomas Kuehne wrote:

>>For the "enum" stress tests, I notice that a semicolon is used to end
>>the enum declaration.  The D standard declares them without a semicolon
>>appended.  Would removing the semicolon change the stress test results?
> 
> Thanks, I removed the semicolon. The change had no impact.

If D had supported warnings, it would probably be appropriate
to issue one for extra semicolons after enum and class and such...
But since it doesn't, it's really not enough to trigger an error.

Maybe it (D) does need some kind of -pedantic flag, like GCC has ?
"verify program according to the standard and strict specification"
(do some "lint" checks that takes forever but sometimes catches bugs?)

--anders
December 12, 2004
Anders schrieb:
>>>For the "enum" stress tests, I notice that a semicolon is used to end the enum declaration.  The D standard declares them without a semicolon appended.  Would removing the semicolon change the stress test results?
>>
>> Thanks, I removed the semicolon. The change had no impact.
>
> If D had supported warnings, it would probably be appropriate
> to issue one for extra semicolons after enum and class and such...
> But since it doesn't, it's really not enough to trigger an error.
>
> Maybe it (D) does need some kind of -pedantic flag, like GCC has ? "verify program according to the standard and strict specification" (do some "lint" checks that takes forever but sometimes catches bugs?)

http://digitalmars.com/d/statement.html#expression
# Expressions that have no affect, like (x + x), are illegal in expression
# statements.

"" (empty) has no affect, thus it's illegal.

Thomas

diff -ur dmd-109/dmd/src/dmd/parse.c neu/dmd/src/dmd/parse.c
- --- dmd-109/dmd/src/dmd/parse.c 2004-12-03 01:19:56.000000000 +0100
+++ neu/dmd/src/dmd/parse.c 2004-12-12 12:15:46.857412128 +0100
@@ -475,6 +475,7 @@
      }

      case TOKsemicolon:  // empty declaration
+      error("empty declaration in front of semicolon");
   nextToken();
   continue;

December 12, 2004
Thomas Kuehne wrote:

> http://digitalmars.com/d/statement.html#expression
> # Expressions that have no affect, like (x + x), are illegal in expression
> # statements.
> 
> "" (empty) has no affect, thus it's illegal.

True, then it *should* be made into an error after all...

Right now there seems to be NO such warnings implemented in GDC:

> void main()
> {
> };

> void main()
> {
>   ;
> }

> void main()
> {
>   null;
> }

> void main()
> {
>   int x;
>   (x + x);
> }

GCC says "warning: statement with no effect" for 3) and 4) above
(i.e. for the C versions of them, changed to "int main()") and for
1) "warning: ISO C does not allow extra `;' outside of a function"

Losing the extra semicolon after *some* declarations
is a Good Thing, even if it makes it C-incompatible ?
(a little like functions with no arguments, or casts)

--anders
December 13, 2004
Thomas Kuehne wrote:
> John Reimer schrieb:
> 
>>Thomas Kuehne wrote:
>>
>>>http://svn.kuehne.cn/dstress/run/break_03.d
>>>http://svn.kuehne.cn/dstress/run/break_04.d
>>>http://svn.kuehne.cn/dstress/run/break_05.d
>>>http://svn.kuehne.cn/dstress/nocompile/command_line_deprecated_02.d
>>>http://svn.kuehne.cn/dstress/run/delegate_04.d
>>>http://svn.kuehne.cn/dstress/nocompile/delegate_05.d
>>>http://svn.kuehne.cn/dstress/run/delegate_12.d
>>>http://svn.kuehne.cn/dstress/run/enum_07.d
>>>http://svn.kuehne.cn/dstress/run/enum_08.d
>>>http://svn.kuehne.cn/dstress/run/enum_09.d
>>>http://svn.kuehne.cn/dstress/complex/linking/ (linking_01)
>>>http://svn.kuehne.cn/dstress/nocompile/static_08.d
> 
> 
>>For the "enum" stress tests, I notice that a semicolon is used to end
>>the enum declaration.  The D standard declares them without a semicolon
>>appended.  Would removing the semicolon change the stress test results?
> 
> 
> Thanks, I removed the semicolon. The change had no impact.
> 
> Thomas
> 
> 

Perhaps the semicolon is indeed optional.  I now see that the D language docs actual use a semicolon to end an enum in some examples, although it doesn't seem to appear in the actual enum definition portion of the docs.  I guess it's probably just one of those C carry-over features.

- John
December 13, 2004
John Reimer wrote:
> Thomas Kuehne wrote:
> 
>>
>> Thanks, I removed the semicolon. The change had no impact.
>>
>> Thomas
>>
>>
> 
> Perhaps the semicolon is indeed optional.  I now see that the D language docs actual use a semicolon to end an enum in some examples, although it doesn't seem to appear in the actual enum definition portion of the docs.  I guess it's probably just one of those C carry-over features.
> 
> - John

As far as I can tell DMD doesn't care if you have empty statements (just as comments are ignored). I don't have a problem with that. If you're relying on ";" to do something, I don't think a warning or an error is going to help you much.

On the other hand, I understand why "int i; i;" should be disallowed. I can see all kinds of bugs that can be prevented by prohibiting that.

By the way, DMD compiles the following code without complaint:


;
;
;



enum
{
    item1,
    item2,
    item3
}


enum
{
    a,
    b,
    c
};


int main()
{
    ;
    ;
    return 1;

}


My two cents...

-- 
Justin (a/k/a jcc7)
http://jcc_7.tripod.com/d/
December 14, 2004
Hello Justin,

Yeah... you are probably right.  D's flexibility with spurious semicolons is probably not something to lose sleep over. :-)

- John

J C Calvarese wrote:
> John Reimer wrote:
> 
>> Thomas Kuehne wrote:
>>
>>>
>>> Thanks, I removed the semicolon. The change had no impact.
>>>
>>> Thomas
>>>
>>>
>>
>> Perhaps the semicolon is indeed optional.  I now see that the D language docs actual use a semicolon to end an enum in some examples, although it doesn't seem to appear in the actual enum definition portion of the docs.  I guess it's probably just one of those C carry-over features.
>>
>> - John
> 
> 
> As far as I can tell DMD doesn't care if you have empty statements (just as comments are ignored). I don't have a problem with that. If you're relying on ";" to do something, I don't think a warning or an error is going to help you much.
> 
> On the other hand, I understand why "int i; i;" should be disallowed. I can see all kinds of bugs that can be prevented by prohibiting that.
> 
> By the way, DMD compiles the following code without complaint:
> 
> 
> ;
> ;
> ;
> 
> 
> 
> enum
> {
>     item1,
>     item2,
>     item3
> }
> 
> 
> enum
> {
>     a,
>     b,
>     c
> };
> 
> 
> int main()
> {
>     ;
>     ;
>     return 1;
> 
> }
> 
> 
> My two cents...
>