From: "Carlo E. Prelz" Date: 2012-11-01T04:11:40+09:00 Subject: Re: bug?: local variable created in if modifier not available in modified expression Subject: Re: bug?: local variable created in if modifier not available in modified expression Date: Thu 01 Nov 12 03:57:47AM +0900 Quoting Robert Klemme (shortcutter@googlemail.com): > You mean like > > $ ruby -ce 'if a = 9 then puts 1 end' > -e:1: warning: found = in conditional, should be == > Syntax OK > > ? Yes, that's why I really like Ruby. But GCC can also be helpful in this: #!/usr/bin/env ruby File::open('/tmp/test.c','w') do |f| f.write <<-EOF #include int main(int argc,char *argv[]) { int i=1; if(i=3) printf("Bla bla\\n"); return 0; } EOF end system('gcc -o /tmp/test -Wall /tmp/test.c') gcc prints this warning: /tmp/test.c: In function ‘main’: /tmp/test.c:5:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses] Carlo -- * Se la Strada e la sua Virtu' non fossero state messe da parte, * K * Carlo E. Prelz - fluido@fluido.as che bisogno ci sarebbe * di parlare tanto di amore e di rettitudine? (Chuang-Tzu)