Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #11208

Re: Curious compiler warning

From Lew <noone@lewscanon.com>
Newsgroups comp.lang.java.programmer
Subject Re: Curious compiler warning
Date 2012-01-10 18:17 -0800
Organization albasani.net
Message-ID <jeirev$9ou$1@news.albasani.net> (permalink)
References <Xns9FD6D451D5F1Djpnasty@94.75.214.39> <jeir4m$qma$1@dont-email.me>

Show all headers | View raw


On 01/10/2012 06:11 PM, Eric Sosman wrote:
> On 1/10/2012 8:51 PM, Novice wrote:
>> I'm getting an odd compiler warning that I don't really understand. I
>> wonder if anyone can enlighten me on the meaning of this message.
>> Basically, I'm not sure what the compiler's problem is with what I'm doing
>> or the best way to make it happy.
>>
>> I've got a fairly simply method name foo() that takes two parameters, ints
>> called start and finish. During this method, I decrement start and finish
>> and then calls another method, bar(),
>
> Pretty stupid method names.
>
> Knew a guy once (this sounds crazy, but it's a true story) who
> had a hard time inventing variable names. So he wrote himself a
> little program to generate random names and printed out a sheet of
> a few hundred such. Thereafter, any time he needed a variable name
> and was stuck for a good idea he'd just grab his printout and take
> the next random name -- crossing it off so as not to re-use it and
> create confusion. Result: No one could read his code, not even he.
>
>> passing the decremented versions of
>> start and finish. For some reason, the compiler objects to the statements
>> where I decrement start and finish and says "the parameter should not be
>> assigned". I'm running Eclipse 3.7.1 with a 1.6.18 JDK.
>>
>> So here's what the code looks like:
>>
>> public static int foo(int start, int finish) {
>>
>> /* Other stuff */
>>
>> start--;
>> finish--;
>>
>> bar(start, finish);
>> }
>>
>> It's the start--; and finish--; lines that are raising the warnings.
>>
>> What exactly is wrong with doing that? And what is the best way to make the
>> compiler happy about that code?
>
> There's absolutely nothing wrong with it; Eclipse is acting
> like a nervous maiden aunt, as usual.

No, there is something wrong with it.  It's a wasted assignment

> Somewhere in Eclipse's configuration menus there might be a way
> to tell it to stop worrying about monsters under the bed. (It'll
> probably be on a menu whose color scheme is dark blue on jet black.)
> All I can suggest is that you search for that menu, and hope against
> hope that it actually exists.
>
> If you can't find anti-anxiety medicine for Eclipse, consider
> NetBeans.

You can tune the warning levels in Eclipse, including telling it not to fret 
over assignments to parameters.  Here, though, the question is what the heck 
assigning to the variables accomplishes.  The answer is "nothing useful" and 
the OP should heed Eclipse's advice.

-- 
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Curious compiler warning Novice <novice@example..com> - 2012-01-11 01:51 +0000
  Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 18:10 -0800
    Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 02:36 +0000
      Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 19:03 -0800
        Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 07:50 +0000
          Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 23:57 -0800
        Re: Curious compiler warning Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2012-01-11 05:47 -0400
          Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 13:25 +0000
            Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 06:58 -0800
              Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 07:01 -0800
              Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-11 10:03 -0800
                Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 23:30 -0800
              Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:10 -0800
                Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-11 23:32 -0800
                Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 01:44 -0600
                Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:42 -0800
                Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 10:51 -0600
                Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-12 07:50 -0800
                Re: Curious compiler warning Leif Roar Moldskred <leifm@dimnakorr.com> - 2012-01-12 10:54 -0600
                Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
                Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 11:51 -0800
                Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 20:58 -0800
        Re: Curious compiler warning "Gavino" <invalid@invalid.invalid> - 2012-01-11 20:05 +0100
          Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:47 -0800
        Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
          Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-21 12:13 -0800
    Re: Curious compiler warning Novice <novice@example..com> - 2012-01-11 04:55 +0000
      Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 21:46 -0800
      Re: Curious compiler warning glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2012-01-11 07:55 +0000
      Re: Curious compiler warning Roedy Green <see_website@mindprod.com.invalid> - 2012-01-11 01:35 -0800
        Re: Curious compiler warning "Gavino" <invalid@invalid.invalid> - 2012-01-11 20:05 +0100
          Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:18 -0800
            Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:55 -0800
              Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 11:59 -0800
            Re: Curious compiler warning Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-13 00:02 +0000
              Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-12 16:11 -0800
                Re: Curious compiler warning Martin Gregorie <martin@address-in-sig.invalid> - 2012-01-13 01:31 +0000
          Re: Curious compiler warning Roedy Green <see_website@mindprod.com.invalid> - 2012-01-11 18:26 -0800
            Re: Curious compiler warning Patricia Shanahan <pats@acm.org> - 2012-01-11 19:01 -0800
              Re: Curious compiler warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-11 23:23 -0500
                Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:00 -0800
            Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
          Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 07:50 -0800
        Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:14 -0800
          Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:05 -0800
            Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-12 12:02 -0800
  Re: Curious compiler warning Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-10 21:11 -0500
    Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-10 18:17 -0800
    Re: Curious compiler warning bugbear <bugbear@trim_papermule.co.uk_trim> - 2012-01-11 16:10 +0000
    Re: Curious compiler warning Lars Enderin <lars.enderin@telia.com> - 2012-01-11 20:45 +0100
      Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:09 -0800
      Re: Curious compiler warning Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-01-12 18:14 +0200
      Re: Curious compiler warning Wanja Gayk <brixomatic@yahoo.com> - 2012-01-21 12:52 +0100
      Re: Curious compiler warning David Lamb <dalamb@cs.queensu.ca> - 2012-01-21 09:12 -0500
    Re: Curious compiler warning Gene Wirchenko <genew@ocis.net> - 2012-01-11 18:21 -0800
    Re: Curious compiler warning Lew <noone@lewscanon.com> - 2012-01-12 08:08 -0800
  Re: Eclipse 3.7.1 compiler warning v_borchert@despammed.com (Volker Borchert) - 2012-01-11 21:10 +0000

csiph-web