public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/66857] New: Reference not bound to lvalue
@ 2015-07-13 12:23 sebastian.lauwers at gmail dot com
  2015-07-13 12:24 ` [Bug c++/66857] " sebastian.lauwers at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: sebastian.lauwers at gmail dot com @ 2015-07-13 12:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

            Bug ID: 66857
           Summary: Reference not bound to lvalue
           Product: gcc
           Version: 5.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastian.lauwers at gmail dot com
  Target Milestone: ---

Created attachment 35967
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35967&action=edit
preprocessed code

Reporting this as it seems to be a regression from gcc 4.9.2. The following
code works on gcc 4.9.2, but asserts on gcc 5.1.1:

=========== 8< ==========
#include <cassert>

const int i = 0;

struct Test {
    Test(const int& rhs) {
        assert(&rhs == &i);
    }
};

int main(void) {
    Test test = i;
}
=========== >8 ==========

If line 12 is changed to:

    Test test(i);

The assertion is not triggered.

Please let me know if further information is required.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
@ 2015-07-13 12:24 ` sebastian.lauwers at gmail dot com
  2015-07-13 12:28 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: sebastian.lauwers at gmail dot com @ 2015-07-13 12:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

--- Comment #1 from Sebastian Lauwers <sebastian.lauwers at gmail dot com> ---
Command: g++ -v -save-temps test.cpp

Output:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-linker-hash-style=gnu --enable-plugin --enable-initfini-array
--disable-libgcj --with-default-libstdcxx-abi=c++98 --with-isl --enable-libmpx
--enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 5.1.1 20150618 (Red Hat 5.1.1-4) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/5.1.1/cc1plus -E -quiet -v -D_GNU_SOURCE
test.cpp -mtune=generic -march=x86-64 -fpch-preprocess -o test.ii
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/5.1.1/include-fixed"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../x86_64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1

/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/x86_64-redhat-linux
 /usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../include/c++/5.1.1/backward
 /usr/lib/gcc/x86_64-redhat-linux/5.1.1/include
 /usr/local/include
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/5.1.1/cc1plus -fpreprocessed test.ii
-quiet -dumpbase test.cpp -mtune=generic -march=x86-64 -auxbase test -version
-o test.s
GNU C++ (GCC) version 5.1.1 20150618 (Red Hat 5.1.1-4) (x86_64-redhat-linux)
        compiled by GNU C version 5.1.1 20150618 (Red Hat 5.1.1-4), GMP version
6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (GCC) version 5.1.1 20150618 (Red Hat 5.1.1-4) (x86_64-redhat-linux)
        compiled by GNU C version 5.1.1 20150618 (Red Hat 5.1.1-4), GMP version
6.0.0, MPFR version 3.1.2, MPC version 1.0.2
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a5de1e39a9a4df73d4ab91471f1f5942
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 as -v --64 -o test.o test.s
GNU assembler version 2.25 (x86_64-redhat-linux) using BFD version version
2.25-8.fc22
COMPILER_PATH=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/:/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/:/usr/libexec/gcc/x86_64-redhat-linux/:/usr/lib/gcc/x86_64-redhat-linux/5.1.1/:/usr/lib/gcc/x86_64-redhat-linux/
LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/5.1.1/:/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /usr/libexec/gcc/x86_64-redhat-linux/5.1.1/collect2 -plugin
/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/liblto_plugin.so
-plugin-opt=/usr/libexec/gcc/x86_64-redhat-linux/5.1.1/lto-wrapper
-plugin-opt=-fresolution=test.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --build-id
--no-add-needed --eh-frame-hdr --hash-style=gnu -m elf_x86_64 -dynamic-linker
/lib64/ld-linux-x86-64.so.2
/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/crt1.o
/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/crti.o
/usr/lib/gcc/x86_64-redhat-linux/5.1.1/crtbegin.o
-L/usr/lib/gcc/x86_64-redhat-linux/5.1.1
-L/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64 -L/lib/../lib64
-L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../.. test.o
-lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/lib/gcc/x86_64-redhat-linux/5.1.1/crtend.o
/usr/lib/gcc/x86_64-redhat-linux/5.1.1/../../../../lib64/crtn.o


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
  2015-07-13 12:24 ` [Bug c++/66857] " sebastian.lauwers at gmail dot com
@ 2015-07-13 12:28 ` redi at gcc dot gnu.org
  2015-07-13 13:07 ` [Bug c++/66857] [5/6 Regression] " redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-13 12:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-13
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] [5/6 Regression] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
  2015-07-13 12:24 ` [Bug c++/66857] " sebastian.lauwers at gmail dot com
  2015-07-13 12:28 ` redi at gcc dot gnu.org
@ 2015-07-13 13:07 ` redi at gcc dot gnu.org
  2015-07-13 23:44 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-13 13:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The gimple dump shows a temporary int being created from the global, and the
temporary is passed to the constructor.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] [5/6 Regression] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
                   ` (2 preceding siblings ...)
  2015-07-13 13:07 ` [Bug c++/66857] [5/6 Regression] " redi at gcc dot gnu.org
@ 2015-07-13 23:44 ` ppalka at gcc dot gnu.org
  2015-07-15 14:24 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2015-07-13 23:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ppalka at gcc dot gnu.org

--- Comment #4 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Reverting the change made to ocp_convert in r217814 fixes it:

diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
index 13bc1f7..6d4bd9a 100644
--- a/gcc/cp/cvt.c
+++ b/gcc/cp/cvt.c
@@ -687,7 +687,8 @@ ocp_convert (tree type, tree expr, int convtype, int flags,
     }

   /* FIXME remove when moving to c_fully_fold model.  */
-  e = scalar_constant_value (e);
+  if (!CLASS_TYPE_P (type))
+    e = scalar_constant_value (e);
   if (error_operand_p (e))
     return error_mark_node;


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] [5/6 Regression] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
                   ` (3 preceding siblings ...)
  2015-07-13 23:44 ` ppalka at gcc dot gnu.org
@ 2015-07-15 14:24 ` jason at gcc dot gnu.org
  2015-07-25 23:16 ` ppalka at gcc dot gnu.org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2015-07-15 14:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Patrick Palka from comment #4)
> Reverting the change made to ocp_convert in r217814 fixes it:
> 
> diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c
> index 13bc1f7..6d4bd9a 100644
> --- a/gcc/cp/cvt.c
> +++ b/gcc/cp/cvt.c
> @@ -687,7 +687,8 @@ ocp_convert (tree type, tree expr, int convtype, int
> flags,
>      }
> 
>    /* FIXME remove when moving to c_fully_fold model.  */
> -  e = scalar_constant_value (e);
> +  if (!CLASS_TYPE_P (type))
> +    e = scalar_constant_value (e);
>    if (error_operand_p (e))
>      return error_mark_node;

This fix is OK.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] [5/6 Regression] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
                   ` (4 preceding siblings ...)
  2015-07-15 14:24 ` jason at gcc dot gnu.org
@ 2015-07-25 23:16 ` ppalka at gcc dot gnu.org
  2015-08-14 16:33 ` jason at gcc dot gnu.org
  2015-08-14 16:33 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: ppalka at gcc dot gnu.org @ 2015-07-25 23:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Author: ppalka
Date: Sat Jul 25 23:15:44 2015
New Revision: 226228

URL: https://gcc.gnu.org/viewcvs?rev=226228&root=gcc&view=rev
Log:
Fix PR c++/66857

gcc/cp/ChangeLog:

        PR c++/66857
        * cvt.c (ocp_convert): Don't call scalar_constant_value when
        converting to a class type.

gcc/testsuite/ChangeLog:

        PR c++/66857
        * g++.dg/init/pr66857.C: New test.


Added:
    trunk/gcc/testsuite/g++.dg/init/pr66857.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cvt.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] [5/6 Regression] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
                   ` (5 preceding siblings ...)
  2015-07-25 23:16 ` ppalka at gcc dot gnu.org
@ 2015-08-14 16:33 ` jason at gcc dot gnu.org
  2015-08-14 16:33 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-14 16:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |5.3

--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug c++/66857] [5/6 Regression] Reference not bound to lvalue
  2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
                   ` (6 preceding siblings ...)
  2015-08-14 16:33 ` jason at gcc dot gnu.org
@ 2015-08-14 16:33 ` jason at gcc dot gnu.org
  7 siblings, 0 replies; 9+ messages in thread
From: jason at gcc dot gnu.org @ 2015-08-14 16:33 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66857

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Fri Aug 14 16:33:10 2015
New Revision: 226897

URL: https://gcc.gnu.org/viewcvs?rev=226897&root=gcc&view=rev
Log:
Fix PR c++/66857

gcc/cp/ChangeLog:

        PR c++/66857
        * cvt.c (ocp_convert): Don't call scalar_constant_value when
        converting to a class type.

gcc/testsuite/ChangeLog:

        PR c++/66857
        * g++.dg/init/pr66857.C: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/init/pr66857.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/cvt.c


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-14 16:33 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-13 12:23 [Bug c++/66857] New: Reference not bound to lvalue sebastian.lauwers at gmail dot com
2015-07-13 12:24 ` [Bug c++/66857] " sebastian.lauwers at gmail dot com
2015-07-13 12:28 ` redi at gcc dot gnu.org
2015-07-13 13:07 ` [Bug c++/66857] [5/6 Regression] " redi at gcc dot gnu.org
2015-07-13 23:44 ` ppalka at gcc dot gnu.org
2015-07-15 14:24 ` jason at gcc dot gnu.org
2015-07-25 23:16 ` ppalka at gcc dot gnu.org
2015-08-14 16:33 ` jason at gcc dot gnu.org
2015-08-14 16:33 ` jason 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).