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

Clang-cl error on missing exception specification 'throw()' #25639

Closed
llvmbot opened this issue Oct 20, 2015 · 5 comments
Closed

Clang-cl error on missing exception specification 'throw()' #25639

llvmbot opened this issue Oct 20, 2015 · 5 comments
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 20, 2015

Bugzilla Link 25265
Resolution FIXED
Resolved on Oct 20, 2015 15:49
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @majnemer,@rnk

Extended Description

Clang-cl will produce an error when a definition doesn't match the declaration containing a 'throw()'. I believe this is correct behavior, however MSVC will silently ignore this and compile. This was originally seen attempting to pull in the atltime.h header, but can be reproduced with the following:

class Foo {
int Bar() const throw();
};

int Foo::Bar() const {
return 0;
}

1>Source.cpp(7,10): error : 'Bar' is missing exception specification 'throw()'

I expect clang-cl with the -fms-extensions option should allow this to compile with a warning, as it's very difficult to change the ATL headers.

Note: Flipping the throw specification to the definition seems to produce an expected warning:

class Foo {
int Bar() const ;
};

int Foo::Bar() const throw() {
return 0;
}

1>Source.cpp(7,10): warning : exception specification in declaration does not match previous declaration [-Wmicrosoft-exception-spec]

@majnemer
Copy link
Mannequin

majnemer mannequin commented Oct 20, 2015

Drivehappy, can this be reproduced just by including atltime.h ?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 20, 2015

Drivehappy, can this be reproduced just by including atltime.h ?

Yes it can, and was originally where I observed it - through several methods in the CTime class. I had added my reproduce code to display the issue more easily.

@majnemer
Copy link
Mannequin

majnemer mannequin commented Oct 20, 2015

Mark, I don't believe you have attached anything.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 20, 2015

[Small reproduce case, build clang-cl with https://user-images.githubusercontent.com/60944935/143752270-0d78f7e3-ef75-4c2c-855c-fd2a397ebc72.gz)
I've attached the reproduce case. I've realized this also requires the MSVC exception flag to clang:

clang-cl /EHsc Source.cpp

@majnemer
Copy link
Mannequin

majnemer mannequin commented Oct 20, 2015

Fixed in r250854

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang:frontend Language frontend issues, e.g. anything involving "Sema"
Projects
None yet
Development

No branches or pull requests

1 participant