[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-03-04 Thread jakub at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

Jakub Jelinek  changed:

   What|Removed |Added

   Target Milestone|8.4 |8.5

--- Comment #8 from Jakub Jelinek  ---
GCC 8.4.0 has been released, adjusting target milestone.

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-02-07 Thread rguenth at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
   Target Milestone|--- |8.4

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-02-06 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

--- Comment #7 from Jason Merrill  ---
Created attachment 47793
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47793=edit
Fix

This patch fixes the pre-P1825 bug, but breaks the PR58051 test which is not
actually allowed by DR 1579 (but is by P1825), and some of your
-Wredundant-move tests for the same reason.  I think let's wait to see what the
committee thinks before deciding how to resolve this.

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-02-06 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

--- Comment #6 from Marek Polacek  ---
(In reply to Jason Merrill from comment #5)
> I think this is a bug in pre-P1825R0 handling of the restriction that the
> first overload resolution fails "if the type of the first parameter of the
> selected constructor is not an rvalue reference to the object's type
> (possibly cv-qualified)".
> 
> But that restriction was removed by P1825R0, and I think this demonstrates a
> problem with that.
>
> Testing a patch.

Will this resolve bug 91427 too?  Sorry, still assigned to me...

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-02-06 Thread jason at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

--- Comment #5 from Jason Merrill  ---
I think this is a bug in pre-P1825R0 handling of the restriction that the first
overload resolution fails "if the type of the first parameter of the selected
constructor is not an rvalue reference to the object's type (possibly
cv-qualified)".

But that restriction was removed by P1825R0, and I think this demonstrates a
problem with that.

Testing a patch.

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

--- Comment #4 from Marek Polacek  ---
Jason, do you want to change anything here?  Though clang/icc/msvc++ seem to
choose #1.

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-01-30 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

--- Comment #3 from Marek Polacek  ---
Happens with a class too:

struct T { int i; };

struct X {
  X(T&) { }  // #1
  X(const T&) { __builtin_abort (); } // #2
};

X
fn ()
{
  T buf;
  return buf;
}

int
main()
{
  X c = fn ();
}

is it actually a bug though, not just a consequence of Core 1579?  We treat
'buf' as an rvalue and you can't bind an rvalue to a non-const lvalue ref, so
#2 is chosen.

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-01-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

Marek Polacek  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |mpolacek at gcc dot 
gnu.org

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-01-29 Thread mpolacek at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

Marek Polacek  changed:

   What|Removed |Added

 CC||mpolacek at gcc dot gnu.org

--- Comment #2 from Marek Polacek  ---
Simplified, but still run-time test:

struct X {
  X(char (&)[10]) { }
  X(const char (&)[10]) { __builtin_abort (); }
};

X
fn ()
{
  char buf[10];
  return buf;
}

int
main()
{
  X c = fn ();
}

[Bug c++/91212] [8/9/10 Regression] const ignored for ctor arguments within return since r8-2493-g4ce8c5dea53d8073

2020-01-28 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91212

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
  Known to work||7.4.0
   Keywords||wrong-code
   Last reconfirmed||2020-01-28
 CC||jason at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org
 Ever confirmed|0   |1
Summary|const ignored for ctor  |[8/9/10 Regression] const
   |arguments within return |ignored for ctor arguments
   ||within return since
   ||r8-2493-g4ce8c5dea53d8073
  Known to fail||10.0, 8.3.0, 9.2.0

--- Comment #1 from Martin Liška  ---
Confirmed, started with r8-2493-g4ce8c5dea53d8073.

Slightly modified test-case:

$ cat pr91212.cc
extern "C" {
long write( int fd, const void *buf, unsigned long count );
}

struct X {
template  X(const char ()[N]) {
__builtin_printf ("X(const char ()[N])\n");
}
template  X(char ()[N]) {
__builtin_printf("X(char ()[N])\n");
}
};

X
func1()
{
char buf[2048];
return buf;
}

X
func2()
{
char buf[4096];
return X(buf);
}

int
main()
{
char buf[1024];

__builtin_printf("1: ");
X a( buf );
__builtin_printf("2: ");
X b( "x" );
__builtin_printf("3: ");
X c = func1();
__builtin_printf("4: ");
X d = func2();
}