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

Violation of One #531

Open
hjmjohnson opened this Issue Feb 23, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@hjmjohnson
Copy link
Member

hjmjohnson commented Feb 23, 2019

Description

Building with "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=ON" causes many warnings related to -Wodr.

/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:99:7: warning: type ‘struct LogTester’ violates the C++ One Definition Rule [-Wodr]
class LogTester
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkThreadLoggerTest.cxx:32:7: note: a different type is defined in another translation unit
class LogTester
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:124:20: note: the first difference of corresponding definitions is field ‘m_Logger’
itk::LoggerBase* m_Logger;
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkThreadLoggerTest.cxx:57:16: note: a field of same name but different type is defined in another translation unit
itk::Logger* m_Logger;
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/include/itkLoggerBase.h:42:24: note: type name ‘itk::LoggerBase’ should match type name ‘itk::Logger’
class ITKCommon_EXPORT LoggerBase:public Object
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/include/itkLogger.h:36:24: note: the incompatible type is defined here
class ITKCommon_EXPORT Logger:public LoggerBase
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkThreadLoggerTest.cxx:46:15: warning: ‘logStatic’ violates the C++ One Definition Rule [-Wodr]
static void logStatic(LogTester* tester)
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:113:15: note: type mismatch in parameter 1
static void logStatic(LogTester* tester)
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:99:7: note: type ‘struct LogTester’ itself violates the C++ One Definition Rule
class LogTester
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkThreadLoggerTest.cxx:32:7: note: the incompatible type is defined here
class LogTester
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:113:15: note: ‘logStatic’ was previously declared here
static void logStatic(LogTester* tester)
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkThreadLoggerTest.cxx:38:8: warning: ‘log’ violates the C++ One Definition Rule [-Wodr]
void log() {
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:105:8: note: implicit this pointer type mismatch
void log() {
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:99:7: note: type ‘struct LogTester’ itself violates the C++ One Definition Rule
class LogTester
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkThreadLoggerTest.cxx:32:7: note: the incompatible type is defined here
class LogTester
^
/home/johnsonhj/Dashboard/src/ITK/Modules/Core/Common/test/itkLoggerThreadWrapperTest.cxx:105:8: note: ‘log’ was previously declared here
void log() {
^

[Description of the bug]

Steps to Reproduce

  1. Configure with testing on and "CMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=ON"
  2. Build with gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

Expected behavior

Clean build.

Actual behavior

Many real warnings being produced.

Reproducibility

Always on Ubuntu 18.04

Versions

73188f4

Environment

Ununtu 18.04

@hjmjohnson hjmjohnson added the type:Bug label Feb 23, 2019

@hjmjohnson hjmjohnson self-assigned this Feb 23, 2019

@thewtex thewtex added this to the ITK v5.0rc02 milestone Feb 24, 2019

@N-Dekker

This comment has been minimized.

Copy link
Contributor

N-Dekker commented Mar 8, 2019

Looks like a quick-fix could be to place each LogTester definition within an unnamed namespace, within its cxx file.

A more maintainable solution might be to move the LogTester definition into a header file, for example "itkLogTester.h".

My 2 cent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.