{"id":17978560,"url":"https://github.com/mloskot/boost-gil-checksum-bug","last_synced_at":"2025-04-04T00:24:42.548Z","repository":{"id":66812277,"uuid":"242568745","full_name":"mloskot/boost-gil-checksum-bug","owner":"mloskot","description":"Why Boost.GIL legacy tests based on checksum for bit-aligned pixels fail on MSVC 64-bit optimized builds?","archived":false,"fork":false,"pushed_at":"2020-03-10T22:23:23.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T12:21:26.634Z","etag":null,"topics":["boost","boost-gil","bug","image-processing"],"latest_commit_sha":null,"homepage":"https://github.com/boostorg/gil/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mloskot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-23T18:27:25.000Z","updated_at":"2020-03-10T22:23:25.000Z","dependencies_parsed_at":"2023-04-07T14:16:46.881Z","dependency_job_id":null,"html_url":"https://github.com/mloskot/boost-gil-checksum-bug","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mloskot%2Fboost-gil-checksum-bug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mloskot%2Fboost-gil-checksum-bug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mloskot%2Fboost-gil-checksum-bug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mloskot%2Fboost-gil-checksum-bug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mloskot","download_url":"https://codeload.github.com/mloskot/boost-gil-checksum-bug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247099656,"owners_count":20883435,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boost","boost-gil","bug","image-processing"],"created_at":"2024-10-29T17:34:21.465Z","updated_at":"2025-04-04T00:24:42.526Z","avatar_url":"https://github.com/mloskot.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# boost-gil-checksum-bug\n\n\u003e TL;TR: Why Boost.GIL [checksum tests for bit-aligned image](https://github.com/boostorg/gil/blob/2ff2d31895dae665ef3e05d0496bc082470e229c/test/legacy/image.cpp#L373-L381) fail on MSVC 64-bit optimized builds?\n\n[![clang](https://github.com/mloskot/boost-gil-checksum-bug/workflows/clang/badge.svg)](https://github.com/mloskot/boost-gil-checksum-bug/actions?query=workflow:clang)\n[![gcc](https://github.com/mloskot/boost-gil-checksum-bug/workflows/gcc/badge.svg)](https://github.com/mloskot/boost-gil-checksum-bug/actions?query=workflow:gcc)\n[![msvc](https://github.com/mloskot/boost-gil-checksum-bug/workflows/msvc/badge.svg)](https://github.com/mloskot/boost-gil-checksum-bug/actions?query=workflow:msvc)\n[![Build Status](https://dev.azure.com/mloskot/boost-gil-checksum-bug/_apis/build/status/mloskot.boost-gil-checksum-bug?branchName=master)](https://dev.azure.com/mloskot/boost-gil-checksum-bug/_build/latest?definitionId=2\u0026branchName=master)\n\n## Boost.GIL\n\nThe bug was reproduced with GIL from:\n\n- Boost.GIL `develop` branch\n- Boost 1.67 through 1.72 (current release)\n\n## Test\n\nThe [minimal_test.cpp](minimal_test.cpp) performs the following test:\n1. Create 3x3 image based on bit-aligned pixel (`bgr121_image_t`)\n2. Fill image with red\n3. Draw blue diagonal\n\n## Observation\n\nPixels are accessed using `xy_locator` which gives access `x_iterator` and `y_iterator`.\n\nPixels are iterated using `for` loop:\n  - if `x_iterator` is incremented *before* the `y_iterator`, then the blue diagonal is garbled.\n  - if `x_iterator` is incremented *after* the `y_iterator`, then the blue diagonal is drawn correctly - **Where is the BUG?!**\n\nPixels are iterated hand-rolled iteration without `for` loop:\n  - regardless if `++loc.x()` is before or after `--loc.y()`, the blue diagonal is drawn correctly.\n\n## Mystery\n\nThe bug described above leaks **only and only** with 64-bit optimised build using  MSVC++ 14.x\n\n```console\nb2 toolset=msvc variant=release address-model=64 cxxstd=11,14,17,2a\n```\n\nIt is not observed using all these numerous tested compilers:\n\n  - GCC: 4.8, 4.9, 5, 6, 7, 8, 9\n  - Clang: 3.9, 4.0, 5.0, 6.0, 7, 8, 9, 10\n  - XCode: 8.3, 9.0, 9.1, 9.2, 9.3, 9.4, 10\n\n## Run with Boost.Build\n\n```console\nb2.exe -sBOOST_ROOT=D:\\boost.win toolset=msvc cxxstd=11 variant=release,debug address-model=32,64 minimal\n```\n\n## Run with CMake\n\n```console\ncmake -G \"Visual Studio 16 2019\" -A Win32 -B build32 -DBOOST_ROOT=D:/boost.win\ncmake -G \"Visual Studio 16 2019\" -A x64   -B build64 -DBOOST_ROOT=D:/boost.win\n\nset CTEST_OUTPUT_ON_FAILURE=1\nfor %B in (32,64) do ( for %C in (Debug,Release) do (\n    cmake --build build%B --config %C \u0026\u0026 cmake --build build%B --config %C --target RUN_TESTS\n))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmloskot%2Fboost-gil-checksum-bug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmloskot%2Fboost-gil-checksum-bug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmloskot%2Fboost-gil-checksum-bug/lists"}