Greetings,
I maintain the polyml package for the Fedora Linux distrubtion. I was just doing a build with the latest addition to polyml-5.5-fixes when I spotted this compiler output:
elfexport.cpp: In member function 'virtual void ELFExport::exportStore()': elfexport.cpp:612:31: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same pointer type '_memTableEntry*' as the destination; expected '_memTableEntry' or an explicit length [-Wsizeof-pointer-memaccess] memset(memTable, 0, sizeof(memTable));
So only the first pointer-length bytes of memTable are being cleared. Shouldn't that be:
memset(memTable, 0, sizeof(*memTable) * memTableEntries);
?
Regards, -- Jerry James http://www.jamezone.org/
On 10/06/2013 17:11, Jerry James wrote:
Greetings,
I maintain the polyml package for the Fedora Linux distrubtion. I was just doing a build with the latest addition to polyml-5.5-fixes when I spotted this compiler output:
elfexport.cpp: In member function 'virtual void ELFExport::exportStore()': elfexport.cpp:612:31: warning: argument to 'sizeof' in 'void* memset(void*, int, size_t)' call is the same pointer type '_memTableEntry*' as the destination; expected '_memTableEntry' or an explicit length [-Wsizeof-pointer-memaccess] memset(memTable, 0, sizeof(memTable));
So only the first pointer-length bytes of memTable are being cleared. Shouldn't that be:
memset(memTable, 0, sizeof(*memTable) * memTableEntries);
?
Regards,
Jerry James
Thanks for pointing that out. Actually, this was wrong and it shouldn't have been trying to clear memTable at all. It didn't show up because there is a for-loop which clears the first field of each record a bit further along in the code. The remaining fields should not be zeroed here. I've committed a fix to SVN which removes this memset completely.
Regards, David