www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4701] New: Should returning a value in a void function be downgraded to a warning?

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

           Summary: Should returning a value in a void function be
                    downgraded to a warning?
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: ibuclaw ubuntu.com


--- Comment #0 from Iain Buclaw <ibuclaw ubuntu.com> 2010-08-21 02:59:18 PDT ---
The code:
void main()
{
    return true;
}


Results in the compiler error:
test.d(3): Error: long has no effect in expression (true)

Which makes sense, but doesn't really indicate the reasoning very well.
Shouldn't it be instead downgraded to a warning? ie - based on GCC's message:

test.c:(3): Warning: ignoring return value in function returning void

This currently blocks some old D software from building (that, I know, should
really be updated. :)

Regards
Iain

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


Jonathan M Davis <jmdavisProg gmail.com> changed:

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


--- Comment #1 from Jonathan M Davis <jmdavisProg gmail.com> 2010-08-21
04:02:01 PDT ---
1. Walter hates warnings. He pretty much thinks that everything should either
be an error or not. So, you're generally going to have a hard time getting him
to make anything a warning.

2. Returning a value from a void function is outright incorrect. It's not that
it _might_ be incorrect or that it _might_ cause errors. It is _definitely_
incorrect. I have no idea why gcc wouldn't make that an outright error. It
should be. Then again, C is historically lax about a lot of things that you'd
think that it would consider errors, so that's probably why. Still, I see no
reason to make D match gcc is this regard. D makes the correct choice here.

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



--- Comment #2 from Iain Buclaw <ibuclaw ubuntu.com> 2010-08-21 04:29:24 PDT ---
(In reply to comment #1)
 1. Walter hates warnings. He pretty much thinks that everything should either
 be an error or not. So, you're generally going to have a hard time getting him
 to make anything a warning.
 
I beg to differ, but it's his language, so he is allowed to enforce that.
 2. Returning a value from a void function is outright incorrect. It's not that
 it _might_ be incorrect or that it _might_ cause errors. It is _definitely_
 incorrect. I have no idea why gcc wouldn't make that an outright error. It
 should be. Then again, C is historically lax about a lot of things that you'd
 think that it would consider errors, so that's probably why. Still, I see no
 reason to make D match gcc is this regard. D makes the correct choice here.
OK then, when the package maintainer goes chasing up my street for the software affected by the update, I'll let him know it's his fault. ;-) I still think this should be a diagnostic bug though, as the error message does not relate in any way to what the programmer is trying to do. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 21 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4701



--- Comment #3 from Iain Buclaw <ibuclaw ubuntu.com> 2010-08-21 04:36:46 PDT ---
(In reply to comment #2)
 I still think this should be a diagnostic bug though, as the error message does
 not relate in any way to what the programmer is trying to do.
Or accidentally did. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 21 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4701


bearophile_hugs eml.cc changed:

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


--- Comment #4 from bearophile_hugs eml.cc 2010-08-21 04:40:54 PDT ---
This is always bug, no need for warnings here.
The error message is indeed wrong, on it I have bug 3922
So I think this bug report may be closed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 21 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4701


Iain Buclaw <ibuclaw ubuntu.com> changed:

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


--- Comment #5 from Iain Buclaw <ibuclaw ubuntu.com> 2010-08-21 04:47:59 PDT ---
Thanks, marked as dupe. :-)

*** This issue has been marked as a duplicate of issue 3922 ***

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