title: C++ code showing Line 25: Char 5: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
body: <p>Here  is my code:   why does it show compile error??: **non void function does not return a value in all control paths: **</p>
  <pre><code>
  vector&lt;int&gt; twoSum(vector&lt;int&gt;&amp; nums, int target) {     
  
          unordered_map&lt;int,int&gt; m;
          vector&lt;int&gt; v;
          for(int i=0;i&lt;nums.size();i++){
              if(m.count(nums[i])!=0 and nums[i]==target/2){
                  v.push_back(m[nums[i]]);
                  v.push_back(i);
                  return v;
              }
              else if(m.count(nums[i])==0){
                  m[nums[i]]=i;
     
              }            
          }
          for(int i=0;i&lt;nums.size();i++){
              if(m.count(target-nums[i])!=0){
                  v.push_back(i);                
                  v.push_back(m[target-nums[i]]);
                  return v;
              }
          }
      }
  
  </code></pre>