Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86: segmentation.h: fix C++ build error #1417

Merged
merged 1 commit into from
Sep 8, 2017

Conversation

andrewboie
Copy link
Contributor

Signed-off-by: Andrew Boie andrew.p.boie@intel.com

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
@nashif nashif merged commit b8e850b into zephyrproject-rtos:master Sep 8, 2017
@andrewboie andrewboie deleted the cpp-error branch September 8, 2017 19:10
@pfalcon
Copy link
Contributor

pfalcon commented Sep 8, 2017

Maybe I'm dumb, but I didn't get what was wrong from the diff/commit message.

@andrewboie
Copy link
Contributor Author

In C++ designated initializers have to be populated in the order they are specified in the struct definition, for reasons which are unknown to me

@pfalcon
Copy link
Contributor

pfalcon commented Sep 8, 2017

Thanks, that's what I thought (really). But please treat that as a random note re: quality of the commit messages: if there's something unclear, other people can't learn from it and will repeat the mistake. (Yeah, my messages should be better too. ;-).

@lpereira
Copy link
Collaborator

lpereira commented Sep 8, 2017

I suspect it's the same reason initializer lists in constructors have to specify fields in the same order they're in the definition. This wil work:

struct SomeStruct {
    int foo;
    int bar;

    explicit SomeStruct(int foo_, int bar_) : foo(foo_), bar(bar_) {}
};

But writing : bar(...), foo(...) won't. Given that initializer lists are not part of C++ (yet) and are a GCC extension, I suspect that GCC uses that as a syntax sugar to create a constructor (don't quote me on this). In any case, this gives an "official" answer why the order matters.

@andyross
Copy link
Contributor

andyross commented Sep 8, 2017

It's for exactly that reason, yeah. The C++ standard guarantees that members are initialized in the order they appear in the struct. Allowing the constructor initializer expressions to execute in an order other than the one they have in the file was considered to be certifiably insane by the standards committee (of course, the right answer would have been to guarantee to initialize them in the order specified by the initializer list! but they messed up in the original spec that predated constructor initializers).

What's interesting is that GCC applies the same rules to their own named-field struct initializer extension when compiling C++ but not when generating C. I certainly had no clue.

nagineni pushed a commit to nagineni/zephyr that referenced this pull request Nov 20, 2017
The OCF was not able to send packets over BLE 6lowpan
consistently and segfaulting, this patch increase
the data size to help improve stability.

Fixes zephyrproject-rtos#1255, zephyrproject-rtos#1408, zephyrproject-rtos#1415

Signed-off-by: Jimmy Huang <jimmy.huang@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants