Skip to content

Commit

Permalink
c-lib: Cleaner workaround for GCC 11 bug than disabling warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
terryburton committed May 3, 2024
1 parent 86295ca commit 67dce1d
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/c-lib/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -688,22 +688,15 @@ bool gs1_parseDLuri(gs1_encoder* const ctx, char* const dlData, char* const data

out:

if (qp) { // Restore original query parameter delimiter
// *(qp-1) = '?';
dlData[qp - dlData - 1] = '?'; // Ugly hack generates same code as above to satiate GCC 11
}

// Suppress erroneous "error: writing 1 byte into a region of size 0" on GCC 11.2.0
#if __GNUC__ == 11
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif

if (qp) // Restore original query parameter delimiter
*(qp-1) = '?';

if (fr) // Restore original fragment delimiter
*(fr-1) = '#';

#if __GNUC__ == 11
#pragma GCC diagnostic pop
#endif
if (fr) { // Restore original fragment delimiter
// *(fr-1) = '#';
dlData[fr - dlData - 1] = '#'; // Ditto
}

return ret;

Expand Down

0 comments on commit 67dce1d

Please sign in to comment.