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

Compilation warning: "will be initialized after ..." #53

Closed
nbigaouette opened this issue Dec 27, 2013 · 3 comments
Closed

Compilation warning: "will be initialized after ..." #53

nbigaouette opened this issue Dec 27, 2013 · 3 comments

Comments

@nbigaouette
Copy link

Initialization in a constructor is out of order, resulting in a warning (ArchLinux x86_64, gcc version 4.8.2 20131219 (prerelease))

The warning is:

In file included from tools.cpp:4:
serial.h: In copy constructor 'serial::IOException::IOException(const serial::IOException&)':
serial.h:647:15: warning: 'serial::IOException::e_what_' will be initialized after [-Wreorder]
    std::string e_what_;
            ^
serial.h:646:7: warning:   'int serial::IOException::line_' [-Wreorder]
    int line_;
    ^
serial.h:671:3: warning:   when initialized here [-Wreorder]
    IOException (const IOException& other) : e_what_(other.e_what_), line_(other.line_), errno_(other.errno_) {}
@nbigaouette
Copy link
Author

The warning can be fixed using this patch:

diff --git a/include/serial/serial.h b/include/serial/serial.h
index bf664c9..2a915d9 100644
--- a/include/serial/serial.h
+++ b/include/serial/serial.h
@@ -668,7 +668,7 @@ public:
       e_what_ = ss.str();
   }
   virtual ~IOException() throw() {}
-  IOException (const IOException& other) : e_what_(other.e_what_), line_(other.line_), errno_(other.errno_) {}
+  IOException (const IOException& other) : line_(other.line_), e_what_(other.e_what_), errno_(other.errno_) {}

   int getErrorNumber () { return errno_; }

@wjwwood
Copy link
Owner

wjwwood commented Dec 27, 2013

@nbigaouette thanks for the contribution, I'll address this as soon as possible, but a pull request might get merged sooner.

@wjwwood
Copy link
Owner

wjwwood commented Dec 27, 2013

Closing in favor of #54

@wjwwood wjwwood closed this as completed Dec 27, 2013
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

No branches or pull requests

2 participants