Created attachment 46012 [details] Sample code that reproduces the issue Hello, I get the warning "warning: value computed is not used [-Wunused-value]" when compiling the attached code snippet with: g++ test.cpp -fopenmp -Wall -o test This warning is incorrect, as the value referred to by the warning is in fact used. Moreover, the warning does not show up when OpenMP is disabled (by omitting -fopenmp from the command line).
I just compiled this like so: ./bin/g++ test.cpp -fopenmp -Wall -fconcepts -o name test2.cpp and got this on a build from yesterday: g++: internal compiler error: Segmentation fault signal terminated program cc1plus Please submit a full bug report, with preprocessed source if appropriate. See <https://gcc.gnu.org/bugs/> for instructions. This code is linked to another version of this https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88395 as it crashes before your warning issue. I posted to the list here about a possible fix yesterday for it: https://gcc.gnu.org/ml/gcc/2019-03/msg00185.html
(In reply to Nicholas Krause from comment #1) > I just compiled this like so: > ./bin/g++ test.cpp -fopenmp -Wall -fconcepts -o name test2.cpp > and got this on a build from yesterday: > > g++: internal compiler error: Segmentation fault signal terminated program > cc1plus > Please submit a full bug report, > with preprocessed source if appropriate. > See <https://gcc.gnu.org/bugs/> for instructions. > > This code is linked to another version of this > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88395 as it crashes before your > warning issue. I posted to > the list here about a possible fix yesterday for it: > > https://gcc.gnu.org/ml/gcc/2019-03/msg00185.html Could you please explain the connection with this bug? From what I see, what you are reporting here is unrelated to the warning issue, and the segmentation fault only occurs because of your use of the "-fconcepts" flag. Please correct me if I am wrong.
(In reply to Arsène Pérard-Gayot from comment #2) > (In reply to Nicholas Krause from comment #1) > > I just compiled this like so: > > ./bin/g++ test.cpp -fopenmp -Wall -fconcepts -o name test2.cpp > > and got this on a build from yesterday: > > > > g++: internal compiler error: Segmentation fault signal terminated program > > cc1plus > > Please submit a full bug report, > > with preprocessed source if appropriate. > > See <https://gcc.gnu.org/bugs/> for instructions. > > > > This code is linked to another version of this > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88395 as it crashes before your > > warning issue. I posted to > > the list here about a possible fix yesterday for it: > > > > https://gcc.gnu.org/ml/gcc/2019-03/msg00185.html > > Could you please explain the connection with this bug? From what I see, what > you are reporting here is unrelated to the warning issue, and the > segmentation fault only occurs because of your use of the "-fconcepts" flag. > Please correct me if I am wrong. Yes that's correct. However the problem is that it needs to compile and you would get this: test.cpp:2:5: error: ‘concept’ does not name a type 2 | concept bool Concept2 = requires (T t, U u) | ^~~~~~~ test.cpp:2:5: note: ‘concept’ only available with ‘-fconcepts’ test.cpp:8:5: error: ‘concept’ does not name a type 8 | concept bool Concept = Concept2 <T, T>; | ^~~~~~~ test.cpp:8:5: note: ‘concept’ only available with ‘-fconcepts’ test.cpp:12:19: error: ‘Concept’ has not been declared 12 | template <Concept T> | ^~~~~~~ test.cpp:13:35: error: ‘T’ was not declared in this scope 13 | constexpr S& operator += (T o); | ^ test.cpp:13:38: error: declaration of ‘operator+=’ as non-function 13 | constexpr S& operator += (T o); | ^ test.cpp: In function ‘constexpr S operator*(S, S)’: test.cpp:17:18: error: no match for ‘operator+=’ (operand types are ‘S’ and ‘S’) 17 | return a += b; | ~~^~~~ test2.cpp: In member function ‘void S::test(size_t&)’: test2.cpp:21:21: warning: value computed is not used [-Wunused-value] 21 | #pragma omp atomic capture | ^~~ Therefore it must be build must and that bug fixed first before we take on this bug unless you can send me a example without concepts required and just openmp code.
(In reply to Nicholas Krause from comment #3) > (In reply to Arsène Pérard-Gayot from comment #2) > > (In reply to Nicholas Krause from comment #1) > > > I just compiled this like so: > > > ./bin/g++ test.cpp -fopenmp -Wall -fconcepts -o name test2.cpp > > > and got this on a build from yesterday: > > > > > > g++: internal compiler error: Segmentation fault signal terminated program > > > cc1plus > > > Please submit a full bug report, > > > with preprocessed source if appropriate. > > > See <https://gcc.gnu.org/bugs/> for instructions. > > > > > > This code is linked to another version of this > > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88395 as it crashes before your > > > warning issue. I posted to > > > the list here about a possible fix yesterday for it: > > > > > > https://gcc.gnu.org/ml/gcc/2019-03/msg00185.html > > > > Could you please explain the connection with this bug? From what I see, what > > you are reporting here is unrelated to the warning issue, and the > > segmentation fault only occurs because of your use of the "-fconcepts" flag. > > Please correct me if I am wrong. > > Yes that's correct. However the problem is that it needs to compile and you > would get this: > test.cpp:2:5: error: ‘concept’ does not name a type > 2 | concept bool Concept2 = requires (T t, U u) > | ^~~~~~~ > test.cpp:2:5: note: ‘concept’ only available with ‘-fconcepts’ > test.cpp:8:5: error: ‘concept’ does not name a type > 8 | concept bool Concept = Concept2 <T, T>; > | ^~~~~~~ > test.cpp:8:5: note: ‘concept’ only available with ‘-fconcepts’ > test.cpp:12:19: error: ‘Concept’ has not been declared > 12 | template <Concept T> > | ^~~~~~~ > test.cpp:13:35: error: ‘T’ was not declared in this scope > 13 | constexpr S& operator += (T o); > | ^ > test.cpp:13:38: error: declaration of ‘operator+=’ as non-function > 13 | constexpr S& operator += (T o); > | ^ > test.cpp: In function ‘constexpr S operator*(S, S)’: > test.cpp:17:18: error: no match for ‘operator+=’ (operand types are ‘S’ and > ‘S’) > 17 | return a += b; > | ~~^~~~ > test2.cpp: In member function ‘void S::test(size_t&)’: > test2.cpp:21:21: warning: value computed is not used [-Wunused-value] > 21 | #pragma omp atomic capture > | ^~~ > Therefore it must be build must and that bug fixed first before we take on > this bug unless you can send me a example without concepts required and just > openmp code. Sorry I was compiling a incorrect program your code is fine and this is now confirmed.
Created attachment 46018 [details] gcc9-pr89796.patch Untested fix. You could have used simpler #pragma omp atomic capture prev = c++; that wouldn't warn (so, if you want a workaround, use that).
(In reply to Jakub Jelinek from comment #5) > Created attachment 46018 [details] > gcc9-pr89796.patch > > Untested fix. > > You could have used simpler > #pragma omp atomic capture > prev = c++; > that wouldn't warn (so, if you want a workaround, use that). Thank you for the workaround. Sadly, I cannot apply it to my problem, because in my original code, the increment is not one. I need to do something like: #pragma omp atomic capture { prev = counter; counter += K; }
Author: jakub Date: Tue Mar 26 07:54:02 2019 New Revision: 269933 URL: https://gcc.gnu.org/viewcvs?rev=269933&root=gcc&view=rev Log: PR c++/89796 * semantics.c (finish_omp_atomic): Add warning_sentinel for -Wunused-value around finish_expr_stmt call. * g++.dg/gomp/pr89796.C: New test. * gcc.dg/gomp/pr89796.c: New test. Added: trunk/gcc/testsuite/g++.dg/gomp/pr89796.C trunk/gcc/testsuite/gcc.dg/gomp/pr89796.c Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/semantics.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Tue Apr 30 20:54:16 2019 New Revision: 270741 URL: https://gcc.gnu.org/viewcvs?rev=270741&root=gcc&view=rev Log: Backported from mainline 2019-03-26 Jakub Jelinek <jakub@redhat.com> PR c++/89796 * semantics.c (finish_omp_atomic): Add warning_sentinel for -Wunused-value around finish_expr_stmt call. * g++.dg/gomp/pr89796.C: New test. * gcc.dg/gomp/pr89796.c: New test. Added: branches/gcc-8-branch/gcc/testsuite/g++.dg/gomp/pr89796.C branches/gcc-8-branch/gcc/testsuite/gcc.dg/gomp/pr89796.c Modified: branches/gcc-8-branch/gcc/cp/ChangeLog branches/gcc-8-branch/gcc/cp/semantics.c branches/gcc-8-branch/gcc/testsuite/ChangeLog
Fixed for 9.1+ and 8.4+ so far.
Author: jakub Date: Fri Aug 30 12:32:15 2019 New Revision: 275142 URL: https://gcc.gnu.org/viewcvs?rev=275142&root=gcc&view=rev Log: Backported from mainline 2019-03-26 Jakub Jelinek <jakub@redhat.com> PR c++/89796 * semantics.c (finish_omp_atomic): Add warning_sentinel for -Wunused-value around finish_expr_stmt call. * g++.dg/gomp/pr89796.C: New test. * gcc.dg/gomp/pr89796.c: New test. Added: branches/gcc-7-branch/gcc/testsuite/g++.dg/gomp/pr89796.C branches/gcc-7-branch/gcc/testsuite/gcc.dg/gomp/pr89796.c Modified: branches/gcc-7-branch/gcc/cp/ChangeLog branches/gcc-7-branch/gcc/cp/semantics.c branches/gcc-7-branch/gcc/testsuite/ChangeLog
Fixed.