Bug 102823 - [11/12 Regression] glm-0.9.9.8 fails on gcc-11 and above (-fno-strict-aliasing)
Summary: [11/12 Regression] glm-0.9.9.8 fails on gcc-11 and above (-fno-strict-aliasing)
Status: RESOLVED DUPLICATE of bug 98594
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 11.1.0
: P3 normal
Target Milestone: 11.3
Assignee: Not yet assigned to anyone
URL:
Keywords: alias, wrong-code
Depends on:
Blocks:
 
Reported: 2021-10-18 20:52 UTC by Sergei Trofimovich
Modified: 2021-10-19 09:23 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
z.tar.gz (35.39 KB, application/gzip)
2021-10-18 20:52 UTC, Sergei Trofimovich
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sergei Trofimovich 2021-10-18 20:52:06 UTC
Created attachment 51626 [details]
z.tar.gz

On gcc-10 glm test suite worked successfully. On gcc-11 single test fails as:

glm> The following tests FAILED:
glm>     39 - test-core_func_integer (Failed)

I extracted self-contained example that hopefully illustrates the problem:

$ g++-10 -I. -O2 core_func_integer.cpp -o a && ./a; echo $?
0

$ g++-11 -I. -O2 core_func_integer.cpp -o a && ./a; echo $?
4

$ g++-12 -I. -O2 core_func_integer.cpp -o a && ./a; echo $?
4

Adding -fno-strict-aliasing makes the test pass. Can you help me understand where alaising violation happens? I tried adding -fopt-info, but there is not much difference in the output.
Comment 1 Andrew Pinski 2021-10-18 20:55:34 UTC
Hmm:
*reinterpret_cast<glm::vec<L, typename glm::detail::make_unsigned<T>::type, Q> const *>(&v)

That seems like it could be a violation of C/C++ aliasing rules.


This is in:
	template<glm::length_t L, typename T, glm::qualifier Q>
	static glm::vec<L, int, Q> bitCount_bitfield(glm::vec<L, T, Q> const& v)
Comment 2 Richard Biener 2021-10-19 07:47:01 UTC
Yeah, I think I've seen this exact bug before.  Note while 'int' and 'unsigned' inter-operate wrt TBAA two structure types differing only in the signedness of a _member_ do not.
Comment 3 Richard Biener 2021-10-19 07:48:19 UTC
dup

*** This bug has been marked as a duplicate of bug 98594 ***
Comment 4 Sergei Trofimovich 2021-10-19 09:23:37 UTC
Thank you! Added a link to upstream issue report: https://github.com/g-truc/glm/pull/1087