LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25265 - Clang-cl error on missing exception specification 'throw()'
Summary: Clang-cl error on missing exception specification 'throw()'
Status: RESOLVED FIXED
Alias: None
Product: clang
Classification: Unclassified
Component: Frontend (show other bugs)
Version: trunk
Hardware: PC Windows NT
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-20 12:53 PDT by Mark Harmer
Modified: 2015-10-20 15:49 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
Small reproduce case, build clang-cl with /EHsc (216 bytes, text/plain)
2015-10-20 15:17 PDT, Mark Harmer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Harmer 2015-10-20 12:53:17 PDT
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]
Comment 1 David Majnemer 2015-10-20 12:59:23 PDT
Drivehappy, can this be reproduced just by including atltime.h ?
Comment 2 Mark Harmer 2015-10-20 13:33:15 PDT
(In reply to comment #1)
> 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.
Comment 3 David Majnemer 2015-10-20 14:39:12 PDT
Mark, I don't believe you have attached anything.
Comment 4 Mark Harmer 2015-10-20 15:17:43 PDT
Created attachment 15128 [details]
Small reproduce case, build clang-cl with /EHsc

I've attached the reproduce case. I've realized this also requires the MSVC exception flag to clang:

clang-cl /EHsc Source.cpp
Comment 5 David Majnemer 2015-10-20 15:49:42 PDT
Fixed in r250854