www.digitalmars.com         C & C++   DMDScript  
Archives

D Programming
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.ide
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger
D.gnu
D

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript
electronics


digitalmars.D.bugs - [Issue 3746] New: Misleding error message "OP has no effect in expression XXX), in void function

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

           Summary: Misleding error message "OP  has no effect in
                    expression XXX), in void function
           Product: D
           Version: 2.041
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: baryluk smp.if.uj.edu.pl


--- Comment #0 from Witold Baryluk <baryluk smp.if.uj.edu.pl> 2010-01-27
17:15:05 PST ---
On function with void return type, if one will put expression after return:

void f() {
   auto a = 1, b = 3, c = 5;
   return a/b*c;
}


will end with compiler error like:

aaa.d(4): Error: * has no effect in expression (a / b * c)


My function "f" was lot bigger, and took me about 5 minutes to understand what
is wrong.

Could such bugs can be detected and be something like

aaa.d(4): Error: no return statment allowed in void function/method

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor


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


Bernard Helyer <blood.of.life gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |blood.of.life gmail.com


--- Comment #1 from Bernard Helyer <blood.of.life gmail.com> 2010-01-27
19:59:24 PST ---
Well, obviously return *is* allowed from void functions (void f() { return; }).
But 'error: return statement with a value in a void function' would be a
preferable message than talking about values having no effect in expressions.

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



--- Comment #2 from Witold Baryluk <baryluk smp.if.uj.edu.pl> 2010-01-28
12:12:00 PST ---
(In reply to comment #1)
 Well, obviously return *is* allowed from void functions (void f() { return; }).
 But 'error: return statement with a value in a void function' would be a
 preferable message than talking about values having no effect in expressions.

Yes you are right. Error messages should be as precise as possible. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 28 2010