public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/61719] New: misleading error message
@ 2014-07-05  8:54 drepper.fsp+rhbz at gmail dot com
  2014-07-07 10:11 ` [Bug c++/61719] " manu at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: drepper.fsp+rhbz at gmail dot com @ 2014-07-05  8:54 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: 6259 bytes --]

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

            Bug ID: 61719
           Summary: misleading error message
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: drepper.fsp+rhbz at gmail dot com

This happens with older versions as well and the problem is worse in more
complicated situations.  This is the boiled-down version.  Take this source:

struct c {
  c(int a) : aa(a {}
  int aa;
};

c v(1);


There clearly is a type in the constructor call, the closing parenthesis is
missing.  This causes the scanner to read the remainder of the file looking for
the end of the initializer of the call.  The error messages you get are:

u.cc: In constructor ‘c::c(int)’:
u.cc:2:14: error: class ‘c’ does not have any field named ‘aa’
   c(int a) : aa(a {}
              ^
u.cc:2:19: error: expected ‘)’ before ‘{’ token
   c(int a) : aa(a {}
                   ^
u.cc:3:7: error: expected ‘{’ at end of input
   int aa;
       ^

Yes, the second error points in the right direction but in more complicated
situations there can be even more messages between the first message and the
one in second place here.

It seems that despite an error token being returned when looking for the end of
the initializer for aa the compiler first performs a lookup of the member which
of course makes no sense in this case since the remainder of the class is not
parsed.

I think something better can be done, maybe just skip looking up the member to
be initialized if there is a syntax error in the initializer call itself.
>From gcc-bugs-return-455691-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 05 09:20:30 2014
Return-Path: <gcc-bugs-return-455691-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24249 invoked by alias); 5 Jul 2014 09:20:29 -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 24161 invoked by uid 48); 5 Jul 2014 09:20:17 -0000
From: "husky.puppy at mail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/61720] New: std::regex_search matches incorrectly
Date: Sat, 05 Jul 2014 09:20:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: libstdc++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: husky.puppy at mail 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-61720-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-07/txt/msg00282.txt.bz2
Content-length: 2661

https://gcc.gnu.org/bugzilla/show_bug.cgi?ida720

            Bug ID: 61720
           Summary: std::regex_search matches incorrectly
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: husky.puppy at mail dot com

Created attachment 33072
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3072&actioníit
Preprocessed sourcce code

When using std::regex_search to match the string R"("test\")" against the
regular expression R"("([^"]|\\")*[^\\]")", it incorrectly finds a match. The
std::regex_match on the other hand works as expected.

Source:
#include <regex>
#include <iostream>

int main()
{
  std::string test = R"("test\")";
  std::regex regex(R"("([^"]|\\")*[^\\]")");
  std::smatch match;
  std::regex_search(test, match, regex);
  std::cout << "search: " << match.str() << std::endl;
  std::regex_match(test, match, regex);
  std::cout << "match:  " << match.str() << std::endl;
  return 0;
}

Output:
search: "test\"
match:

Command Line:
g++ -std=c++11 -Wall -Werror test.cpp

GCC Info:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.0-9'
--with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap
--disable-vtable-verify --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.0 (Debian 4.9.0-9)

System Info:
Linux server 3.14-1-amd64 #1 SMP Debian 3.14.9-1 (2014-06-30) x86_64 GNU/Linux


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

* [Bug c++/61719] misleading error message
  2014-07-05  8:54 [Bug c++/61719] New: misleading error message drepper.fsp+rhbz at gmail dot com
@ 2014-07-07 10:11 ` manu at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: manu at gcc dot gnu.org @ 2014-07-07 10:11 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |error-recovery
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-07-07
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1
           Severity|minor                       |enhancement

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Perhaps the parser could insert the missing parenthesis and continue, but
touching the parser this way is always tricky. There are many much worse cases
of error-recovery. Compared with Clang, we don't do so bad here:

test.cc:4:9: error: expected ')'
  int aa;
        ^
test.cc:3:16: note: to match this '('
  c(int a) : aa(a {}
               ^

Given the amount of bugs needing attention, I think this will be very low in
the priority queue. But if you wish to take a look, the code is in
gcc/cp/parser.c.
>From gcc-bugs-return-455752-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 07 10:37:46 2014
Return-Path: <gcc-bugs-return-455752-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 22310 invoked by alias); 7 Jul 2014 10:37:45 -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 22109 invoked by uid 48); 7 Jul 2014 10:37:36 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/61677] False positive with -Wmaybe-uninitialized (test case included)
Date: Mon, 07 Jul 2014 10:37:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords: diagnostic, missed-optimization
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: NEW
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: keywords bug_status
Message-ID: <bug-61677-4-ypLOfpi248@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-61677-4@http.gcc.gnu.org/bugzilla/>
References: <bug-61677-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-07/txt/msg00343.txt.bz2
Content-length: 1972

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|WAITING                     |NEW

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Josh Triplett from comment #4)
> Created attachment 33067 [details]
> Reduced testcase
> 
> Here's a reduced testcase.

[CHECK] Found def edge 1 in jump_23 = PHI <jump_16(D)(13), jump_18(11)>
[BEFORE SIMPLICATION -- [USE]:
jump_23->offset = 42;
is guarded by :

i_19 != -1(OVF) (.AND.) _8 != 0


[BEFORE NORMALIZATION --[USE]:
jump_23->offset = 42;
is guarded by :

i_19 != -1(OVF) (.AND.) _8 != 0


[AFTER NORMALIZATION -- [USE]:
jump_23->offset = 42;
is guarded by :

menu_7(D) != 0B (.AND.) i_19 != -1(OVF)


[BEFORE SIMPLICATION -- [DEF]:
jump_23 = PHI <jump_16(D)(13), jump_18(11)>
is guarded by :

_8 != 0 (.AND.)  (.NOT.) _12 != 0


[BEFORE NORMALIZATION --[DEF]:
jump_23 = PHI <jump_16(D)(13), jump_18(11)>
is guarded by :

_8 != 0 (.AND.)  (.NOT.) _12 != 0


[AFTER NORMALIZATION -- [DEF]:
jump_23 = PHI <jump_16(D)(13), jump_18(11)>
is guarded by :

 (.NOT.) _12 != 0 (.AND.) menu_7(D) != 0B


[CHECK]: Found unguarded use: jump_23->offset = 42;


There is something wrong in the computation of the guard-conditions. Perhaps
the computation is not powerful enough to realize that "(.NOT.) _12 != 0" has
to appear also in the use.

It seems also that VRP is not powerful enough here:

  # RANGE [0, 2147483645] NONZERO 15
  # i_3 = PHI <i_19(8), i_34(5)>
  # .MEM_6 = PHI <.MEM_13(8), .MEM_24(5)>
  [test.c : 14:11] # RANGE [-1, 2147483644]
  i_19 = i_3 + -1;
  [test.c : 14:11] if (i_19 != -1(OVF))

The range should be [0, 8].
>From gcc-bugs-return-455753-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Jul 07 10:43:02 2014
Return-Path: <gcc-bugs-return-455753-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 28026 invoked by alias); 7 Jul 2014 10:43:01 -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 27914 invoked by uid 48); 7 Jul 2014 10:42:57 -0000
From: "joaquin at tid dot es" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/61732] New: Derivation from final class incorrectly allowed
Date: Mon, 07 Jul 2014 10:43: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: 4.8.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: joaquin at tid dot es
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
Message-ID: <bug-61732-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-07/txt/msg00344.txt.bz2
Content-length: 614

https://gcc.gnu.org/bugzilla/show_bug.cgi?ida732

            Bug ID: 61732
           Summary: Derivation from final class incorrectly allowed
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joaquin at tid dot es

I understand that [class]/3 marks this program as ill-formed:

template<class Base> struct derived:Base{};

struct X final{};

void foo(derived<X>*){}

int main()
{
  foo(0);
}

Yet it builds and runs fine in GCC 4.8.


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

end of thread, other threads:[~2014-07-07 10:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-05  8:54 [Bug c++/61719] New: misleading error message drepper.fsp+rhbz at gmail dot com
2014-07-07 10:11 ` [Bug c++/61719] " manu 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).