Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove two tests from test_logging_apis.cc (#19100)
### Description In some environments the test code has undefined behavior. To prove it, save the following code as test.cpp ```c++ #include <iostream> #include <stdio.h> int main(){ char buf[1024]; int ret = snprintf(buf, sizeof(buf), "%ls","abc"); if(ret <0){ std::cout<< ret<< std::endl; } else{ std::cout<< "OK: ret="<<ret<< std::endl; } return 0; } ``` Then compile it as ``` g++ -DNDEBUG -std=gnu++17 test.cpp -o /tmp/t ``` Or ``` g++ -O2 -DNDEBUG -std=gnu++17 test.cpp -o /tmp/t ``` The first command is without optimization. The second one turns on optimization. Then the outputs are different. When optimization is enabled, the output might be: ``` OK: ret=-1 ``` You cannot explain why it would go to this branch when ret is "-1". It might be a bug of a specific version of GCC. However, at this moment we cannot change the version. It was found in GCC version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC) that is provided by UBI8. RHEL9 doesn't have the problem. snprintf is a builtin function of GCC. So the problem was not related to glibc. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. -->
- Loading branch information