last_hour's blog

By last_hour, history, 5 days ago, In English

Heyo Codefoworcers! As I was practicing some of the problems, I came across the problem 1553C - Penalty and while solving this I literally blown up CF OJ and my Laptop!!!

The fact is my submission 280945613 gets AC while getting {warning: control reaches end of non-void function [-Wreturn-type]} this on my laptop and also this is not the end!

**The code breaks the range i from 0 to <n = 10 and proceeds to i=10 ...you can check it out I ran this code on ideone.com it just works perfectly fine there as well, I literally don't have any idea about this. Even I changed compiler it still gets an AC. Drop your thoughts on it!

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
5 days ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Are you sure that it is actually possible to reach the end of the loop? Probably you just can't do that and return always works before reaching the end.

Or maybe it just returns some value and it luckily doesn't affect the answer

  • »
    »
    5 days ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    it returns I made a mistake

    but what it does is break the for loop condition still doesn't affect anything like it reaches iteration i =10

    • »
      »
      »
      5 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Well, then it's UB and you are very lucky Maybe compiler is somehow thinking that if loop is ended it should return n+1 xd

      • »
        »
        »
        »
        5 days ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        at the end of for loop, even if i write return i+1 it still remains the same

        why is that so

        I changed compiler still getting AC :')

»
5 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by last_hour (previous revision, new revision, compare).