public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60399] New: constexpr ctor that does not init an attribute should be rejected but isn't
@ 2014-03-03 10:23 wouter at voti dot nl
  2014-03-03 18:47 ` [Bug c++/60399] " daniel.kruegler at googlemail dot com
  2014-11-19  9:44 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: wouter at voti dot nl @ 2014-03-03 10:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60399

            Bug ID: 60399
           Summary: constexpr ctor that does not init an attribute should
                    be rejected but isn't
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wouter at voti dot nl

Created attachment 32250
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32250&action=edit
cpp stanalone main file that shows the problem

AFAIK A constexpr constructor that does not initialize all attributes should be
rejected. In the attached code, which is accepted by the compiler, such a
constructor is invoked in the initialization of a static class attribute.

To my surprise the compiler generates an init_array entry for this (which is
what triggered me to dig into this, I work with a linkerscript that does not
allow any int_array entries). The generated entry is basically empty, just

static done = false;
if( ! done ){
   done = true;
}

When I make the constexpr constructor initialize the attribute the init_array
entry is gone.

I use GCC for ARM, 4.8.3

"C:/Program Files (x86)/GNU Tools ARM Embedded/4.8
2013q4/bin/arm-none-eabi-g++" -nostartfiles  -mcpu=cortex-m0 -mthumb
-fomit-frame-pointer -march=armv6-m -Wall -Werror -Wno-unused-local-typedefs
-Wno-maybe-uninitialized -fdata-sections -ffunction-sections -Os -fno-rtti
-fno-exceptions  -fno-threadsafe-statics -fno-use-cxa-get-exception-ptr
-std=c++11 -c -o main.o main.cpp


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

* [Bug c++/60399] constexpr ctor that does not init an attribute should be rejected but isn't
  2014-03-03 10:23 [Bug c++/60399] New: constexpr ctor that does not init an attribute should be rejected but isn't wouter at voti dot nl
@ 2014-03-03 18:47 ` daniel.kruegler at googlemail dot com
  2014-11-19  9:44 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-03-03 18:47 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 9205 bytes --]

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60399

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
No, the compiler is conforming: According to 7.1.6 p6:

"If the instantiated template specialization of a constexpr [..] member
function of a class template would fail to satisfy the requirements for a
constexpr function or constexpr constructor, that specialization is still a
constexpr function or constexpr constructor, even though a call to such a
function
cannot appear in a constant expression."

So, per se, the situation is well-defined here and there is fundamentally
nothing wrong with the constructor, because your code does not attempt to use
it in a constant expression. 

What makes your code ill-formed is the fact that your template could never be
instantiated to make the constructor a constexpr constructor, see the following
sentence:

"If no specialization of the template would satisfy the requirements for
a constexpr function or constexpr constructor when considered as a non-template
function or constructor, the template is ill-formed; no diagnostic required."

As you may notice, this kind of code does not require a diagnostics.
>From gcc-bugs-return-445329-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Mar 03 19:30:36 2014
Return-Path: <gcc-bugs-return-445329-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 3527 invoked by alias); 3 Mar 2014 19:30:35 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 3088 invoked by uid 48); 3 Mar 2014 19:30:28 -0000
From: "fredrik at lysator dot liu.se" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/58638] libstdc++ builds as non-PIC when --with-pic is specified
Date: Mon, 03 Mar 2014 19:30:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: fredrik at lysator dot liu.se
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-58638-4-FQLDAuj0Qe@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58638-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58638-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-03/txt/msg00198.txt.bz2
Content-length: 1640

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58638

Fredrik Nyström <fredrik at lysator dot liu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fredrik at lysator dot liu.se

--- Comment #3 from Fredrik Nyström <fredrik at lysator dot liu.se> ---
Seems to be a bug in libstdc++-v3/configure, same in both gcc-4.8 and gcc-4.9.

Suggested fix:

--- libstdc++-v3/configure~     2013-11-22 14:17:55.000000000 +0100
+++ libstdc++-v3/configure      2014-03-03 20:01:32.000000000 +0100
@@ -14909,25 +14909,25 @@
 # libtool variables for C++ shared and position-independent compiles.
 #
 # Use glibcxx_lt_pic_flag to designate the automake variable
 # used to encapsulate the default libtool approach to creating objects
 # with position-independent code. Default: -prefer-pic.
 #
 # Use glibcxx_compiler_shared_flag to designate a compile-time flags for
 # creating shared objects. Default: -D_GLIBCXX_SHARED.
 #
 # Use glibcxx_compiler_pic_flag to designate a compile-time flags for
 # creating position-independent objects. This varies with the target
 # hardware and operating system, but is often: -DPIC -fPIC.
-if test "$enable_shared" = yes; then
+if test "$enable_shared" = yes || test "${with_pic+set}" = set; then
   glibcxx_lt_pic_flag="-prefer-pic"
   glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX"
   glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED"

 else
   glibcxx_lt_pic_flag=
   glibcxx_compiler_pic_flag=
   glibcxx_compiler_shared_flag=
 fi
>From gcc-bugs-return-445330-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Mar 03 19:31:33 2014
Return-Path: <gcc-bugs-return-445330-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 4410 invoked by alias); 3 Mar 2014 19:31:33 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 4380 invoked by uid 48); 3 Mar 2014 19:31:30 -0000
From: "nate.mcnamara at morganstanley dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60402] New: const overload with variadics declared ambiguous according to standard (may be related to bug 58156)
Date: Mon, 03 Mar 2014 19:31:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: nate.mcnamara at morganstanley dot com
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-60402-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-03/txt/msg00199.txt.bz2
Content-length: 2327

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`402

            Bug ID: 60402
           Summary: const overload with variadics declared ambiguous
                    according to standard (may be related to bug 58156)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nate.mcnamara at morganstanley dot com

Created attachment 32255
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id2255&actioníit
preprocessed source

$ g++ -v
Reading specs from
/ms/dist/fsf/PROJ/gcc/4.8.1/.exec/@sys/lib/gcc/x86_64-unknown-linux-gnu/4.8.1/specs
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/ms/dist/fsf/PROJ/gcc/4.8.1/.exec/@sys/libexec/gcc/x86_64-unknown-linux-gnu/4.8.1/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: //ms/dev/fsf/gcc/4.8.1/src/gcc-4.8.1/configure
--prefix=//ms/dist/fsf/PROJ/gcc/4.8.1/.exec/x86_64.linux.2.6.glibc.2.3
--exec-prefix=//ms/dist/fsf/PROJ/gcc/4.8.1/.exec/x86_64.linux.2.6.glibc.2.3
--disable-checking --enable-threads=posix --enable-__cxa_atexit
--enable-languages=c,c++,fortran
--with-gmp=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3
--with-mpfr=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3
--with-mpc=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3
--enable-linker-build-id
--with-cloog=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3
--with-isl=//ms/dev/fsf/gcc/4.8.1/install/.exec/x86_64.linux.2.6.glibc.2.3
--with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 4.8.1 (GCC)
$ g++ -std=c++11 ambiguous.cpp
ambiguous.cpp: In instantiation of 'void f(const char*, T ...) [with T {int}]':
ambiguous.cpp:12:14:   required from here
ambiguous.cpp:7:51: warning: ISO C++ says that these are ambiguous, even though
the worst conversion for the first is better than the worst conversion for the
second: [enabled by default]
   f(const_cast<char*>(s), std::forward<T>(args)...);
                                                   ^
ambiguous.cpp:6:6: note: candidate 1: void f(const char*, T ...) [with T {int}]
 void f(const char* s, T... args) {
      ^
ambiguous.cpp:3:6: note: candidate 2: void f(char*, ...)
 void f(char* s, ...) {}
      ^


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

* [Bug c++/60399] constexpr ctor that does not init an attribute should be rejected but isn't
  2014-03-03 10:23 [Bug c++/60399] New: constexpr ctor that does not init an attribute should be rejected but isn't wouter at voti dot nl
  2014-03-03 18:47 ` [Bug c++/60399] " daniel.kruegler at googlemail dot com
@ 2014-11-19  9:44 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2014-11-19  9:44 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Closing then.


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

end of thread, other threads:[~2014-11-19  9:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-03 10:23 [Bug c++/60399] New: constexpr ctor that does not init an attribute should be rejected but isn't wouter at voti dot nl
2014-03-03 18:47 ` [Bug c++/60399] " daniel.kruegler at googlemail dot com
2014-11-19  9:44 ` paolo.carlini at oracle dot com

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).