- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include#include#include "omp.h"using namespace std;int main(){omp_set_num_threads(8);#pragma omp parallel forfor(int i=0; i< 3000; i++){int asdf=2;try{cerr << "Im " << omp_get_thread_num()<<" out of " << omp_get_num_threads()< } catch (exception& e){//asdf=0;continue;}}return 0;}
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you turn on openmp-report to see if you could get any comments from the compiler?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
--mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
--mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Microsoft C/C++ compiler ignores acontent of a'catch(...)' or 'catch( exception &e )'blocks if all
optimizations are disabled and the compileroutputs a warning:
Warning C4702: Unreachable code
It doesn't matter what was implemented in the block anda content is simply ignored!
Is it expected or not?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--mark
Hi Mark,
Could you verify that a Warning Level in your project is set to 'Level 4 (/W4)'?I'll also verifythe
codewith VS2008 and VS2010.
Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's what I get:
>cl /W4 -openmp t.cpp -c -EHsc -Od
Microsoft 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
t.cpp
t.cpp(9) : warning C4189: 'asdf' : local variable is initialized but not referenced
t.cpp(12) : warning C4101: 'e' : unreferenced local variable
d:\NOBACKUP\quadtests\forum\102618>icl /W4 -Qopenmp t.cpp -c -EHsc -Od
Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.2.278 Build 20111128
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
t.cpp
t.cpp(12): remark #177: handler parameter "e" was declared but never referenced
} catch (exception& e){
^
t.cpp(9): remark #177: variable "asdf" was declared but never referenced
int asdf=2;
^
d:\NOBACKUP\quadtests\forum\102618>
>icl /W4 -Qopenmp t.cpp -c -EHsc -Od
Intel C++ Intel 64 Compiler XE for applications running on Intel 64, Version 12.1.2.278 Build 20111128
Copyright (C) 1985-2011 Intel Corporation. All rights reserved.
t.cpp
t.cpp(12): remark #177: handler parameter "e" was declared but never referenced
} catch (exception& e){
^
t.cpp(9): remark #177: variable "asdf" was declared but never referenced
int asdf=2;
^
Thanks,
--mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here are results of my verification:
VS2005 Professional - Debug - Warning C4702: unreachable code
- Release - No warning
VS2008 Professional - Debug - Warning C4702: unreachable code
- Release - No warning
VS2008 Express - Debug - Warning C4702: unreachable code
- Release - No warning
VS2010 Express - Debug - Warning C4702: unreachable code
- Release - No warning
As you ca see there is noWarning C4702 for Release configurations andI'm a little bit concerned. Is that a feature or a bug?
Some project settings are as follows: /W4 /Od ( All optimizations disabled ) /GR /openmp
Best regards,
Sergey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks,
--mark

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page