Bug 487849

Summary: Is there any check for QMap creating an item by default when using [] to reference an item?
Product: [Developer tools] clazy Reporter: albrightsteve
Component: generalAssignee: Unassigned bugs <unassigned-bugs-null>
Status: REPORTED ---    
Severity: normal CC: albrightsteve, smartins
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Other   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description albrightsteve 2024-05-31 20:24:57 UTC
If you have a QMap and do if(yourMap[someKey]==someValue) it creates a map item and later on a contains will find it despite the unintentional creation.
Comment 1 albrightsteve 2024-06-03 02:25:59 UTC
I forgot to mention, this violates having const C++ functions too if data members are getting modified.