Comments (11)
Could you try -std=C++20 instead of GNU? Or even some other version of C++. The code in question is the swizzle code, which contains the copy assignment operator inside a union. In the past I've had some issues but this is essential to supporting swizzles, at least the way they work at the moment. For reference, this is the bit of code it's complaining about (and other similar code)
HLSLPP_WARNING_ANONYMOUS_STRUCT_UNION_BEGIN
struct
{
union
{
#include "swizzle/hlsl++_matrix_row0_1.h"
#include "swizzle/hlsl++_matrix_row0_2.h"
#include "swizzle/hlsl++_matrix_row0_3.h"
#include "swizzle/hlsl++_matrix_row0_4.h"
};
union
{
#include "swizzle/hlsl++_matrix_row1_1.h"
#include "swizzle/hlsl++_matrix_row1_2.h"
#include "swizzle/hlsl++_matrix_row1_3.h"
#include "swizzle/hlsl++_matrix_row1_4.h"
};
};
HLSLPP_WARNING_ANONYMOUS_STRUCT_UNION_END
from hlslpp.
Setting it to -std=c++20 doesn't seem to change the error. It is still there. I have been searching the G++ docs to see if there is a way I can force G++ to just accept it because MSVC 17.8 and Clang 17 all accept it.
from hlslpp.
I also have a GCC automated build going so not entirely sure what might be tripping it up. I don't know what version AppVeyor uses though, I could take a look. I've also noticed I named it GGC
from hlslpp.
It is also an issue on g++ 11.4.0 which is the OS compiler for Ubuntu 22.04:
g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.4.0-1ubuntu122.04' --with --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-XeT9lY/gcc-11-11.4.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=222.04)
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1
from hlslpp.
Can you give something a try locally? Run ./Linux.sh in the main hlsl++repo, then go to workspace/gmake2 and run make all in there. I'd be curious to see what you get. I have run that locally in Ubuntu and it seems to all compile fine. My version of gcc is 11.4.0 there too
from hlslpp.
Okay that worked. I am now suspecting that CMake is doing something somewhere. I will investigate deeper and get back to you.
from hlslpp.
Okay I figured it out. It was not actually g++, it was CMake outputting a cppcheck complaint about the header but making it look like it was g++ outputting it. I apologize for the confusion.
from hlslpp.
Actually it was not cppcheck. I narrowed it down to one flag I was using: -mavx2 because I was targeting AVX2 CPUs with my code. Removing makes the error go away. Is there a way for me to use this flag without it triggering this error?
from hlslpp.
I see what's going on, this isn't being tested in the build matrix, it's a bit unexpected and I'm not sure how to fix it. Apparently, while GCC is happy to have members with constructors inside an anonymous union, it cannot have members with constructors inside an anonymous struct for some reason.
The reason this only fails with AVX is that we don't use anonymous structs with swizzles inside anywhere else, but this is needed to ensure the swizzles align with the m256 data inside the matrix, i.e.
union
{
m256 data;
struct
{
swizzle0;
swizzle1;
}:
}
I don't really know in what other way to express what I need to happen other than that. Giving the struct a name defeats the entire purpose of this which is to access the swizzles. Do you want to use the AVX2 capabilities of hlsl++ or just use the flag in general? It should be possible to add a define to disable this and force hlsl++ to not use AVX, thereby avoiding the problem. It's a bit sad but perhaps an acceptable workaround.
from hlslpp.
I think I am okay with HLSL++ not using AVX2. GCC is used as just another compiler to verify our code, we build our production code with clang. I will just enable the scalar implementation for HLSL++ for GCC.
from hlslpp.
I want to test an alternate solution to the problem in any case, as you're happy with your solution I'll consider this closed. Let me know if there's any other issues with it, thanks!
from hlslpp.
Related Issues (20)
- Improve HLSL++ unit tests by using full-featured testing framework HOT 2
- Matrix accessor operator HOT 6
- operator / (float1, float3) looks inverted HOT 8
- How well does this cover HLSL202x? HOT 11
- * operator brake mult function in quaternion HOT 7
- Quaternion slerp returning nan values HOT 2
- Clang error: unused variable 't4' in hlsl++_quaternion.h HOT 6
- Upgrade warnings to errors HOT 2
- round() on ARM Neon uses wrong rounding mode HOT 2
- mul() intrinsic is missing some overloads. HOT 2
- clamp() intrinsic is missing overloads for intN HOT 1
- Some non square matrix definitions are incorrect HOT 6
- Missing matrix constructors HOT 2
- Some vector double functions missing HOT 5
- Undefined behavior when accessing vector elements with operator[] HOT 10
- internal::round_float gives incorrect results HOT 4
- Errors on building Linux ARM64 HOT 2
- vcpkg support? HOT 11
- Take address of single-component swizzles HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hlslpp.