S3518 reporting division by zero with double as throwing arithmetic exception

java

(Stephen Palmer) #1

Server Version 6.7.4 (build 38452)
SonarJava 5.8

‘’’ return ((double) variable1 / (double) variable2 > CONSTANT);’’’

as a potential division by zero throwing an arithmetic exception …
… but division by zero with doubles either returns Nan or Infinity; no exception is ever thrown.


(Nicolas Peru) #2

Hi @stephenrpalmer,

Your analysis is spot on, ticket created to handle the issue: https://jira.sonarsource.com/browse/SONARJAVA-3026

Thanks for the feedback,