Issue 148875
Summary False negative in Clang Static Analyzer if an aggregate is initialized with parnthesized list
Labels clang:static analyzer
Assignees
Reporter necto
    [C++20 Enabled treatment parenthesized initialization as aggregate initialization](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html)
Clang Static Analyzer, however, [does not handle it properly](https://compiler-explorer.com/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:1,endLineNumber:14,positionColumn:1,positionLineNumber:14,selectionStartColumn:1,selectionStartLineNumber:14,startColumn:1,startLineNumber:14),source:'struct+Storage+%7B%0A++int+x%3B%0A%7D%3B%0A%0Aint+t1()+%7B%0A++++Storage+w%7B32%7D%3B%0A++++return+1+/+(w.x+-+32)%3B%0A%7D%0A%0Aint+t2()+%7B%0A++++Storage+w(32)%3B%0A++++return+1+/+(w.x+-+32)%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:51.701121955375044,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang201assert,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:'--analyze+-std%3Dc%2B%2B20',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+20.1.0+(assertions)+(Editor+%231)',t:'0')),header:(),k:48.29887804462494,l:'4',m:16.754631264495075,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+20.1.0',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+20.1.0+(assertions)+(Compiler+%231)',t:'0')),header:(),l:'4',m:83.24536873550493,n:'0',o:'',s:0,t:'0')),k:48.29887804462494,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4):
```C++
struct Storage {
  int x;
};

int t1() {
    Storage w{32};
    return 1 / (w.x - 32); // Division by zero reported
}

int t2() {
    Storage w(32);
    return 1 / (w.x - 32); // False negative
}
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to