Alignas broken when used with constexpr array data member for structure
Hi there, In GCC 4.8.4 I have something like the following: constexpr int x = 5; constexpr int y = 4; struct alignas(y) my_data_block { char data[x]; }; And it causes some weird errors to the tune of "size of array ‘data’ is not an integral constant-expression" in the presence of the alignas This is a pretty nasty bug and means it's not implemented as I thought. I don't know the front-ends (but I do actually know GIMPLE-low and below quite well, love the pattern matching) and I'd like to dig more, it's almost certainly fixed - this is just for personal curiosity. Where would I look? A 1 line reply with a directory would be a great start; even if it's just a guess. I did ask in #gcc on freenode - it didn't go so well, sorry to ping you all for this. Alec
Re: Alignas broken when used with constexpr array data member for structure
On 9 January 2018 at 13:15, Alec Teal wrote: > Hi there, > > In GCC 4.8.4 I have something like the following: > > constexpr int x = 5; > > constexpr int y = 4; > > struct alignas(y) my_data_block { > >char data[x]; > > }; > > > And it causes some weird errors to the tune of "size of array ‘data’ is not > an integral constant-expression" in the presence of the alignas > > This is a pretty nasty bug and means it's not implemented as I thought. I > don't know the front-ends (but I do actually know GIMPLE-low and below quite > well, love the pattern matching) and I'd like to dig more, it's almost > certainly fixed - this is just for personal curiosity. > > Where would I look? A 1 line reply with a directory would be a great start; > even if it's just a guess. I told you on IRC, C++ support is implemented in gcc/cp Why do you keep demanding help and then ignore the answer? > I did ask in #gcc on freenode - it didn't go so well, sorry to ping you all > for this. This belongs on gcc-help not this list.
Re: Implementing p0515 - spaceship operator
On 01/08/2018 02:07 PM, Tim van Deurzen wrote: Hi, I've been spending some time the past few weeks implementing p0515r2, i.e. the proposal for consistent comparisons for C++ (aka the spaceship operator). I've received some very valuable help on the IRC channel, but I'm still a little bit stuck. Note, I'm completely new to the GCC codebase and am very much still getting oriented. Following advice from some of the people in IRC channel I implemented parsing the new token in libcpp and I seem to be successfully parsing it and creating a new AST node. As this feature is not in the C++ standard yet, I wanted to add a command line flag to enable usage of the new operator and ignoring it otherwise. I managed to get cc1plus to accept the parameter, but it seems that when I invoke my own g++ binary with that parameter, it complains about unknown parameters. As Jonathan mentioned, you may not need a new option for this. But it's useful to know how to add one in any case. Reading the manual is a good idea but the easiest way to actually add one by far is to look at a simple change that adds in git or svn log one and follow its example. This command will give you such a list: git log -p --grep="New option" Then just look for an option that affects the front-end. A warning options might be a good example. Martin I'm perfectly happy to dig further on my own, but I get the feeling I'm missing some documentation / resource somewhere that might help me out. Is there some documentation about adding and passing around parameters that will be used both in libcpp and the C++ front-end? What would be the best place to look to learn more about how part of GCC this is structured? I want to make sure I go about this correctly. If this is the wrong place to ask for help, please redirect me, so that I don't unnecessarily spam the wrong mailing list :-). Kind regards, Tim.
Re: Implementing p0515 - spaceship operator
On 01/08/2018 05:07 PM, Jason Merrill wrote: On Mon, Jan 8, 2018 at 4:07 PM, Tim van Deurzen wrote: There's a gccint.info documentation file, the Options node seems like what you're looking for. You will want to add a new option to c-family/c.opt. diffing between branches/c++-modules and trunk may be educational, as that has to do similar things to enable the new keywords. nathan -- Nathan Sidwell
Re: Implementing p0515 - spaceship operator
On 01/08/2018 11:28 PM, Jason Merrill wrote: On Mon, Jan 8, 2018 at 5:13 PM, Jonathan Wakely wrote: On 8 January 2018 at 22:07, Jason Merrill wrote: On Mon, Jan 8, 2018 at 4:07 PM, Tim van Deurzen wrote: I've been spending some time the past few weeks implementing p0515r2, i.e. the proposal for consistent comparisons for C++ (aka the spaceship operator). Great! I've received some very valuable help on the IRC channel, but I'm still a little bit stuck. Note, I'm completely new to the GCC codebase and am very much still getting oriented. Following advice from some of the people in IRC channel I implemented parsing the new token in libcpp and I seem to be successfully parsing it and creating a new AST node. As this feature is not in the C++ standard yet, I wanted to add a command line flag to enable usage of the new operator and ignoring it otherwise. I managed to get cc1plus to accept the parameter, but it seems that when I invoke my own g++ binary with that parameter, it complains about unknown parameters. I'm perfectly happy to dig further on my own, but I get the feeling I'm missing some documentation / resource somewhere that might help me out. Is there some documentation about adding and passing around parameters that will be used both in libcpp and the C++ front-end? What would be the best place to look to learn more about how part of GCC this is structured? I want to make sure I go about this correctly. There's a gccint.info documentation file, the Options node seems like what you're looking for. You will want to add a new option to c-family/c.opt. operator<=> is now in the working paper though, so does it need its own option? IMHO it should just be enabled for -std=c++2a and -std=gnu++2a, and not otherwise. Ah, good point. Jason That makes sense, I'll just use the c++2a and gnu++2a flags. Though I'll still take some time to figure out how options work, so that I can add any toggles that (e.g. for warnings) that might be specific to operator<=>. Just to confirm with you, it does make sense to conditionally parse the token for operator<=> in libcpp (i.e. only when the cxx standard being used is >=2a)? I'm just wondering if this does not accidentally affect other front-ends using libcpp? Tim.