Issue 131127
Summary [Clang] Multiple false positives and false negatives in -Whigher-precision-for-complex-division
Labels clang:frontend
Assignees
Reporter Maetveis
    The `-Whigher-precision-for-complex-division` emitted when `-fcomplex-arithmetic=promoted` option is used and the target does not support a higher precison type has multiple false positives and false negatives:
- Clang warns but shouldn't when the divisor is a real value, this is just elementwise division, which is already precise if performed in the lower precision type.
- Clang doesn't warn but should, if the divisor is a complex value but the divident is real.
- Clang doesn't warn but should, if the operation is going to be performed in a different type than the divident due to usual arithmetic conversions and the new type is the largest precision for the target. (e.g. `__complex__ float / __complex__ double`).
- Clang doesn't warn but should when using the `/=` (divide and assign) operator.

[Reproducer on Compiler Explorer](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:1,endLineNumber:20,positionColumn:1,positionLineNumber:20,selectionStartColumn:1,selectionStartLineNumber:20,startColumn:1,startLineNumber:20),source:'double+__complex__+div_complex_real(double+__complex__+a,+double+b)+%7B%0A++++return+a+/+b%3B+//+This+should+not+warn+but+it+does!!%0A%7D%0A%0Adouble+__complex__+div_real_complex(double+a,+double+__complex__+b)+%7B%0A++++return+a+/+b%3B+//+This+should+warn+but+it+doesn!'t.%0A%7D%0A%0Adouble+__complex__+div_assign(double+__complex__+a,+double+__complex__+b)+%7B%0A++++return+a+/%3D+b%3B+//+This+should+warn+but+it+doesn!'t.%0A%7D%0A%0Adouble+__complex__+div_mixed(float+__complex__+a,+double+__complex__+b)+%7B%0A++++return+a+/+b%3B+//+This+should+warn+but+it+doesn!'t.%0A%7D%0A%0Adouble+__complex__+div_mixed(int+__complex__+a,+double+__complex__+b)+%7B%0A++++return+a+/+b%3B+//+This+should+warn+but+it+doesn!'t.%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:30.958904109589042,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-target+aarch64-pc-windows-msvc+-fcomplex-arithmetic%3Dpromoted+-fsyntax-only+-Wno-unused-command-line-argument',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(trunk)+(Editor+%231)',t:'0')),k:50,l:'4',m:50.60104694679994,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(trunk)+(Compiler+%231)',t:'0')),header:(),l:'4',m:49.398953053200046,n:'0',o:'',s:0,t:'0')),k:69.04109589041096,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to