Merge branch 'gcc-12-opt-warns'

Fix warnings in gcc 12 optimized build.

See #22697.
This commit is contained in:
Vadim Zeitlin 2022-08-03 21:49:10 +02:00
commit cc0c55af7b
2 changed files with 13 additions and 4 deletions

View file

@ -519,6 +519,15 @@ public:
const size_t idx = it - begin();
const size_t after = end() - it;
// Unfortunately gcc 12 still complains about use-after-free even
// though our code is correct because it actually optimizes it to be
// wrong, with -O2 or higher, by moving the assignment above below the
// call to reserve() below, so use this hack to avoid the warning with
// it by preventing it from rearranging the code.
#if wxCHECK_GCC_VERSION(12, 1)
__asm__ __volatile__("":::"memory");
#endif
reserve(size() + count);
// the place where the new element is going to be inserted

View file

@ -244,10 +244,10 @@ void SCI_METHOD LexerDMIS::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, i
case SCE_DMIS_KEYWORD:
if (!setDMISWord.Contains(scCTX.ch)) {
char tmpStr[MAX_STR_LEN];
memset(tmpStr, 0, MAX_STR_LEN*sizeof(char));
scCTX.GetCurrent(tmpStr, (MAX_STR_LEN-1));
strncpy(tmpStr, this->UpperCase(tmpStr), (MAX_STR_LEN-1));
char tmpBuf[MAX_STR_LEN];
memset(tmpBuf, 0, MAX_STR_LEN*sizeof(char));
scCTX.GetCurrent(tmpBuf, (MAX_STR_LEN-1));
char* const tmpStr = this->UpperCase(tmpBuf);
if (this->m_minorWords.InList(tmpStr)) {
scCTX.ChangeState(SCE_DMIS_MINORWORD);