]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
circumvent gcc-8 strict aliasing warning 1415/head
authorYann Collet <cyan@fb.com>
Wed, 14 Nov 2018 00:04:35 +0000 (16:04 -0800)
committerYann Collet <cyan@fb.com>
Wed, 14 Nov 2018 00:04:35 +0000 (16:04 -0800)
because gcc considers that
`void* const *`  and `void**` are 2 different types ...

tests/fullbench.c

index 30f07b6cd685c4c6e6be1ec730e4df49a606486f..409de6395da6af0140d497c44aa81e53850d7909 100644 (file)
@@ -515,6 +515,7 @@ static size_t benchMem(U32 benchNb,
 
     /* benchmark loop */
     {   BMK_timedFnState_t* const tfs = BMK_createTimedFnState(g_nbIterations * 1000, 1000);
+        void* const avoidStrictAliasingPtr = &dstBuff;
         BMK_benchParams_t bp;
         BMK_runTime_t bestResult;
         bestResult.sumOfReturn = 0;
@@ -529,12 +530,13 @@ static size_t benchMem(U32 benchNb,
         bp.blockCount = 1;
         bp.srcBuffers = &src;
         bp.srcSizes = &srcSize;
-        bp.dstBuffers = (void* const*) &dstBuff;
+        bp.dstBuffers = (void* const*) avoidStrictAliasingPtr;  /* circumvent strict aliasing warning on gcc-8,
+                                                                 * because gcc considers that `void* const *`  and `void**` are 2 different types */
         bp.dstCapacities = &dstBuffSize;
         bp.blockResults = NULL;
 
         for (;;) {
-            BMK_runOutcome_t const bOutcome = BMK_benchTimedFn( tfs, bp);
+            BMK_runOutcome_t const bOutcome = BMK_benchTimedFn(tfs, bp);
 
             if (!BMK_isSuccessful_runOutcome(bOutcome)) {
                 DISPLAY("ERROR benchmarking function ! ! \n");