public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function
@ 2020-07-13 8:58 agadethrowaway at gmail dot com
2020-07-13 9:08 ` [Bug c++/96179] [10/11 Regression] " redi at gcc dot gnu.org
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: agadethrowaway at gmail dot com @ 2020-07-13 8:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
Bug ID: 96179
Summary: g++-10.1 silently doesn't push_back the return of a
void function
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: agadethrowaway at gmail dot com
Target Milestone: ---
Created attachment 48866
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48866&action=edit
Minimal reproducing example
#include <vector>
using namespace std;
struct dummy{
int a;
};
void Modify_Dummy(dummy &d){
d.a=1;
}
template <bool bla=true> void Templated_Function(){
vector<dummy> A;
A.push_back(Modify_Dummy(dummy{0}));
}
int main(){
Templated_Function();
}
Compiled with
all:
g++-10 Void_Pushback.cpp -o Void_Pushback
using:
g++-10 (Ubuntu 10-20200411-0ubuntu1) 10.0.1 20200411 (experimental) [master
revision bb87d5cc77d:75961caccb7:f883c46b4877f637e0fa5025b4d6b5c9040ec566]
Copy of code attached.
Code should not compile. The push_back instruction is silently ignored and the
vector stays empty.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96179] [10/11 Regression] g++-10.1 silently doesn't push_back the return of a void function
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
@ 2020-07-13 9:08 ` redi at gcc dot gnu.org
2020-07-13 9:19 ` jakub at gcc dot gnu.org
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2020-07-13 9:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.2
CC| |mpolacek at gcc dot gnu.org
Summary|g++-10.1 silently doesn't |[10/11 Regression] g++-10.1
|push_back the return of a |silently doesn't push_back
|void function |the return of a void
| |function
Ever confirmed|0 |1
Known to work| |9.3.1
Keywords| |accepts-invalid
Known to fail| |10.1.1, 11.0
Last reconfirmed| |2020-07-13
Status|UNCONFIRMED |NEW
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Confirmed. This started with r10-7096 (like PR 95789).
A reduced example shows that GCC even warns the vector variable is unused:
template<typename T> struct vector
{
void push_back(T) { }
};
struct dummy{
int a;
};
void Modify_Dummy(dummy &d){
d.a=1;
}
template <bool bla=true> void Templated_Function(){
vector<dummy> A;
A.push_back(Modify_Dummy(dummy{0}));
}
int main(){
Templated_Function();
}
96179.C: In instantiation of 'void Templated_Function() [with bool bla =
true]':
96179.C:20:28: required from here
96179.C:15:23: warning: variable 'A' set but not used
[-Wunused-but-set-variable]
15 | vector<dummy> A;
| ^
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96179] [10/11 Regression] g++-10.1 silently doesn't push_back the return of a void function
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
2020-07-13 9:08 ` [Bug c++/96179] [10/11 Regression] " redi at gcc dot gnu.org
@ 2020-07-13 9:19 ` jakub at gcc dot gnu.org
2020-07-13 12:59 ` mpolacek at gcc dot gnu.org
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-07-13 9:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
Priority|P3 |P2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96179] [10/11 Regression] g++-10.1 silently doesn't push_back the return of a void function
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
2020-07-13 9:08 ` [Bug c++/96179] [10/11 Regression] " redi at gcc dot gnu.org
2020-07-13 9:19 ` jakub at gcc dot gnu.org
@ 2020-07-13 12:59 ` mpolacek at gcc dot gnu.org
2020-07-13 17:35 ` mpolacek at gcc dot gnu.org
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-13 12:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |mpolacek at gcc dot gnu.org
Status|NEW |ASSIGNED
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96179] [10/11 Regression] g++-10.1 silently doesn't push_back the return of a void function
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
` (2 preceding siblings ...)
2020-07-13 12:59 ` mpolacek at gcc dot gnu.org
@ 2020-07-13 17:35 ` mpolacek at gcc dot gnu.org
2020-07-14 20:03 ` cvs-commit at gcc dot gnu.org
2020-07-14 23:24 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-07-13 17:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|ASSIGNED |RESOLVED
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
This is also fixed by the patch for PR 95789. But another test is useful.
*** This bug has been marked as a duplicate of bug 95789 ***
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96179] [10/11 Regression] g++-10.1 silently doesn't push_back the return of a void function
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
` (3 preceding siblings ...)
2020-07-13 17:35 ` mpolacek at gcc dot gnu.org
@ 2020-07-14 20:03 ` cvs-commit at gcc dot gnu.org
2020-07-14 23:24 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-14 20:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:8e64d182850560dbedfabb88aac90d4fc6155067
commit r11-2097-g8e64d182850560dbedfabb88aac90d4fc6155067
Author: Marek Polacek <polacek@redhat.com>
Date: Mon Jun 22 21:26:49 2020 -0400
c++: Make convert_like complain about bad ck_ref_bind again [PR95789]
convert_like issues errors about bad_p conversions at the beginning
of the function, but in the ck_ref_bind case, it only issues them
after we've called convert_like on the next conversion.
This doesn't work as expected since r10-7096 because when we see
a conversion from/to class type in a template, we return early, thereby
missing the error, and a bad_p conversion goes by undetected. That
made the attached test to compile even though it should not.
I had thought that I could just move the ck_ref_bind/bad_p errors
above to the rest of them, but that regressed diagnostics because
expr then wasn't converted yet by the nested convert_like_real call.
So, for bad_p conversions, do the normal processing, but still return
the IMPLICIT_CONV_EXPR to avoid introducing trees that the template
processing can't handle well. This I achieved by adding a wrapper
function.
gcc/cp/ChangeLog:
PR c++/95789
PR c++/96104
PR c++/96179
* call.c (convert_like_real_1): Renamed from convert_like_real.
(convert_like_real): New wrapper for convert_like_real_1.
gcc/testsuite/ChangeLog:
PR c++/95789
PR c++/96104
PR c++/96179
* g++.dg/conversion/ref4.C: New test.
* g++.dg/conversion/ref5.C: New test.
* g++.dg/conversion/ref6.C: New test.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Bug c++/96179] [10/11 Regression] g++-10.1 silently doesn't push_back the return of a void function
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
` (4 preceding siblings ...)
2020-07-14 20:03 ` cvs-commit at gcc dot gnu.org
@ 2020-07-14 23:24 ` cvs-commit at gcc dot gnu.org
5 siblings, 0 replies; 7+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-14 23:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96179
--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Marek Polacek
<mpolacek@gcc.gnu.org>:
https://gcc.gnu.org/g:315b87f63bcde4c881e9963c39d57258da08ccb5
commit r10-8497-g315b87f63bcde4c881e9963c39d57258da08ccb5
Author: Marek Polacek <polacek@redhat.com>
Date: Mon Jun 22 21:26:49 2020 -0400
c++: Make convert_like complain about bad ck_ref_bind again [PR95789]
convert_like issues errors about bad_p conversions at the beginning
of the function, but in the ck_ref_bind case, it only issues them
after we've called convert_like on the next conversion.
This doesn't work as expected since r10-7096 because when we see
a conversion from/to class type in a template, we return early, thereby
missing the error, and a bad_p conversion goes by undetected. That
made the attached test to compile even though it should not.
I had thought that I could just move the ck_ref_bind/bad_p errors
above to the rest of them, but that regressed diagnostics because
expr then wasn't converted yet by the nested convert_like_real call.
So, for bad_p conversions, do the normal processing, but still return
the IMPLICIT_CONV_EXPR to avoid introducing trees that the template
processing can't handle well. This I achieved by adding a wrapper
function.
gcc/cp/ChangeLog:
PR c++/95789
PR c++/96104
PR c++/96179
* call.c (convert_like_real_1): Renamed from convert_like_real.
(convert_like_real): New wrapper for convert_like_real_1.
gcc/testsuite/ChangeLog:
PR c++/95789
PR c++/96104
PR c++/96179
* g++.dg/conversion/ref4.C: New test.
* g++.dg/conversion/ref5.C: New test.
* g++.dg/conversion/ref6.C: New test.
(cherry picked from commit 8e64d182850560dbedfabb88aac90d4fc6155067)
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-07-14 23:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-13 8:58 [Bug c++/96179] New: g++-10.1 silently doesn't push_back the return of a void function agadethrowaway at gmail dot com
2020-07-13 9:08 ` [Bug c++/96179] [10/11 Regression] " redi at gcc dot gnu.org
2020-07-13 9:19 ` jakub at gcc dot gnu.org
2020-07-13 12:59 ` mpolacek at gcc dot gnu.org
2020-07-13 17:35 ` mpolacek at gcc dot gnu.org
2020-07-14 20:03 ` cvs-commit at gcc dot gnu.org
2020-07-14 23:24 ` cvs-commit at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).