Skip to content

imgcodecs: compile warning at test-avif.cpp #24792

@Kumataro

Description

@Kumataro

System Information

OpenCV version: 4.x ( 4.9.0 )
Operating System / Platform: Ubuntu 23.10 (x86-64)
Compiler & compiler version: gcc version 13.2.0 (Ubuntu 13.2.0-4ubuntu3)

Detailed description

When AVIF codec is enabled, a compile warning occurs at test_avif.cpp.

Source code:

bool result;
EXPECT_NO_THROW(
result = cv::imencode(".avif", img_original, buf, encoding_params_););
EXPECT_TRUE(result);

Warning message:

[1/2] Building CXX object modules/imgcodecs/CMakeFiles/opencv_test_imgcodecs.dir/test/test_avif.cpp.o
In file included from /home/kmtr/work/opencv/modules/ts/include/opencv2/ts.hpp:128,
                 from /home/kmtr/work/opencv/modules/imgcodecs/test/test_precomp.hpp:7,
                 from /home/kmtr/work/opencv/modules/imgcodecs/test/test_avif.cpp:8:
/home/kmtr/work/opencv/modules/imgcodecs/test/test_avif.cpp: In member function ‘virtual void opencv_test::{anonymous}::Imgcodecs_Avif_Image_EncodeDecodeSuite_imencode_imdecode_Test::Body()’:
/home/kmtr/work/opencv/modules/ts/include/opencv2/ts/ts_gtest.h:9274:3: warning: ‘result’ may be used uninitialized [-Wmaybe-uninitialized]
 9274 |   if (const ::testing::AssertionResult gtest_ar_ = \
      |   ^~
/home/kmtr/work/opencv/modules/ts/include/opencv2/ts/ts_gtest.h:21796:3: note: in expansion of macro ‘GTEST_TEST_BOOLEAN_’
21796 |   GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \
      |   ^~~~~~~~~~~~~~~~~~~
/home/kmtr/work/opencv/modules/imgcodecs/test/test_avif.cpp:172:3: note: in expansion of macro ‘EXPECT_TRUE’
  172 |   EXPECT_TRUE(result);
      |   ^~~~~~~~~~~
/home/kmtr/work/opencv/modules/imgcodecs/test/test_avif.cpp:169:8: note: ‘result’ was declared here
  169 |   bool result;
      |        ^~~~~~
[2/2] Linking CXX executable bin/opencv_test_imgcodecs

Steps to reproduce

  1. apt install libavif-dev
  2. cmake -S opencv -B build4-main -DWITH_AVIF=on
  3. cmake --build

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions