public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal
@ 2015-08-03 12:40 tower120 at gmail dot com
  2015-08-03 12:42 ` [Bug c++/67100] " tower120 at gmail dot com
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: tower120 at gmail dot com @ 2015-08-03 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 67100
           Summary: ICE(in type_dependent_expression_p) on macro function
                    + user defined literal
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tower120 at gmail dot com
  Target Milestone: ---

Live errors : #http://goo.gl/UlaJI7

The following code:
//-------------------------------------------------------------------------

#include <typeinfo>
#include <tuple>

#define CAT1(A, B) A ## B
#define CAT(A, B) CAT1(A, B)

#define TOKEN_TO_STRING(TOK) # TOK
#define STRINGIZE_TOKEN(TOK) TOKEN_TO_STRING(TOK)


template <char... chars>
using _tstring = std::integer_sequence<char, chars...>;

template <typename T, T... chars>
constexpr _tstring<chars...> operator""_tstr() { return { }; }

#define tstring(STR) decltype( CAT( TOKEN_TO_STRING(STR), _tstr) )



#define dispatch_forward_fn(fn_name, prefix) \
template<class Caller, class Me> \
struct Dispatcher<Caller, tstring(go_up), Me>{ \
    template<class ...Args, class ...ArgsRef> \
    inline decltype(auto) operator() (ArgsRef&&... args) {\
        return 0; \
    } \
};

#define dispatch_list_prefix \
template<class Caller, class Fn_name, class Me> \
struct Dispatcher; \
dispatch_forward_fn(go_up, _d)


dispatch_list_prefix

int main(){
    Dispatcher<void, tstring(go_up), void>()();
    return 0;
}


//-------------------------------------------------------------------------

Produces following error at gcc 4.9.2 (any flags):

/tmp/gcc-explorer-compiler11573-68-zk0erd/example.cpp: In instantiation of
'struct Dispatcher<void, std::integer_sequence<char, 'g', 'o', '_', 'u', 'p'>,
void>':
40 : required from here
37 : internal compiler error: in type_dependent_expression_p, at cp/pt.c:21020


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

* [Bug c++/67100] ICE(in type_dependent_expression_p) on macro function + user defined literal
  2015-08-03 12:40 [Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal tower120 at gmail dot com
@ 2015-08-03 12:42 ` tower120 at gmail dot com
  2015-08-03 13:34 ` trippels at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: tower120 at gmail dot com @ 2015-08-03 12:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from tower120 <tower120 at gmail dot com> ---
if change 

#define dispatch_forward_fn(fn_name, prefix) \
template<class Caller, class Me> \
struct Dispatcher<Caller, tstring(go_up), Me>{ /* Problem here tstring(go_up)
*/\
    template<class ...Args, class ...ArgsRef> \
    inline decltype(auto) operator() (ArgsRef&&... args) {\
        return 0; \
    } \
};



with:


#define dispatch_forward_fn(fn_name, prefix) \
template<class Caller, class Me> \
using H_##fn_name = tstring(fn_name); \
struct Dispatcher<Caller, H_##fn_name, Me>{ \
    template<class ...Args, class ...ArgsRef> \
    inline decltype(auto) operator() (ArgsRef&&... args) {\
        return 0; \
    } \
};

ICE does not occurs.


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

* [Bug c++/67100] ICE(in type_dependent_expression_p) on macro function + user defined literal
  2015-08-03 12:40 [Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal tower120 at gmail dot com
  2015-08-03 12:42 ` [Bug c++/67100] " tower120 at gmail dot com
@ 2015-08-03 13:34 ` trippels at gcc dot gnu.org
  2015-08-03 13:59 ` tower120 at gmail dot com
  2015-08-19  9:37 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-08-03 13:34 UTC (permalink / raw)
  To: gcc-bugs

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

Markus Trippelsdorf <trippels at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-08-03
                 CC|                            |trippels at gcc dot gnu.org
      Known to work|                            |5.2.0, 6.0
     Ever confirmed|0                           |1
      Known to fail|                            |4.9.3

--- Comment #2 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
markus@x4 tmp % cat te.ii
template <typename _Tp, _Tp...> struct A {};
template <char... chars> using _tstring = A<char, chars...>;
template <typename T, T... chars> _tstring<chars...> operator""_tstr();
template <class, class, class> struct Dispatcher;
template <class Caller, class Me>
struct Dispatcher<Caller, decltype("go_up"_tstr), Me> {
  template <class> decltype(0) operator()();
};
int main() { Dispatcher<void, decltype("go_up"_tstr), void>(); }

markus@x4 tmp % /usr/x86_64-pc-linux-gnu/gcc-bin/4.9.3/g++ -std=c++14 te.ii
te.ii: In instantiation of ‘struct Dispatcher<void, A<char, 'g', 'o', '_', 'u',
'p'>, void>’:
te.ii:9:61:   required from here
te.ii:6:36: internal compiler error: in type_dependent_expression_p, at
cp/pt.c:21026
>From gcc-bugs-return-493938-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Aug 03 13:38:36 2015
Return-Path: <gcc-bugs-return-493938-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 56216 invoked by alias); 3 Aug 2015 13:38:36 -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 55851 invoked by uid 48); 3 Aug 2015 13:38:23 -0000
From: "miyuki at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/55095] Wshift-overflow
Date: Mon, 03 Aug 2015 13:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.0
X-Bugzilla-Keywords: diagnostic
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: miyuki at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: FIXED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-55095-4-qSdKRux9Ka@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-55095-4@http.gcc.gnu.org/bugzilla/>
References: <bug-55095-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: 2015-08/txt/msg00080.txt.bz2
Content-length: 1631

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

Mikhail Maltsev <miyuki at gcc dot gnu.org> changed:

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

--- Comment #16 from Mikhail Maltsev <miyuki at gcc dot gnu.org> ---
(In reply to Marek Polacek from comment #15)
> Yea, I'm afraid we'll have to do what you suggest.  And warn for the sign
> bit only when -Wshift-overflow=2.

Actually for me it looks like the correct way to handle this case. I mean, in
c-family/c-common.c we have:

/* Warn if signed left shift overflows.  We don't warn
   about left-shifting 1 into the sign bit in C++14; cf.
   <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3367.html#1457>
...

And this check is implemented like this:

  /* Handle the left-shifting 1 into the sign bit case.  */
  if (integer_onep (op0)
      && compare_tree_int (op1, prec0 - 1) == 0)

But in fact, even though the defect report explicitly mentions the "1 << x"
case, the resolution is more general. It says:

...if E1 has a signed type and non-negative value, and E1 ⨯ 2^E2 is
representable in the *corresponding unsigned type of the* result type, then
that *value, converted to the result type,* is the resulting value; otherwise,
the behavior is undefined.

I.e., we should not warn for (0x1f << 27) either, at least when compiling C++14
code. But it seems reasonable to use the same logic for earlier dialects of C++
and C when -Wshift-overflow=1, as it is done now.
>From gcc-bugs-return-493939-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Aug 03 13:56:04 2015
Return-Path: <gcc-bugs-return-493939-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 110356 invoked by alias); 3 Aug 2015 13:56:03 -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 110312 invoked by uid 55); 3 Aug 2015 13:56:00 -0000
From: "mpolacek at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/67088] Incorrect location of error on invalid type used in bit-field declaration
Date: Mon, 03 Aug 2015 13:56:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mpolacek at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: mpolacek at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-67088-4-bUqfzk0z2w@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-67088-4@http.gcc.gnu.org/bugzilla/>
References: <bug-67088-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: 2015-08/txt/msg00081.txt.bz2
Content-length: 626

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Author: mpolacek
Date: Mon Aug  3 13:55:28 2015
New Revision: 226506

URL: https://gcc.gnu.org/viewcvs?rev"6506&root=gcc&view=rev
Log:
        PR c/67088
        * c-decl.c (check_bitfield_type_and_width): Add location parameter.
        Use it.
        (grokdeclarator): Pass LOC down to check_bitfield_type_and_width.

        * gcc.dg/pr67088.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/pr67088.c
Modified:
    trunk/gcc/c/ChangeLog
    trunk/gcc/c/c-decl.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/67100] ICE(in type_dependent_expression_p) on macro function + user defined literal
  2015-08-03 12:40 [Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal tower120 at gmail dot com
  2015-08-03 12:42 ` [Bug c++/67100] " tower120 at gmail dot com
  2015-08-03 13:34 ` trippels at gcc dot gnu.org
@ 2015-08-03 13:59 ` tower120 at gmail dot com
  2015-08-19  9:37 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: tower120 at gmail dot com @ 2015-08-03 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from tower120 <tower120 at gmail dot com> ---
Forgot to say - it's ok with gcc 5.1


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

* [Bug c++/67100] ICE(in type_dependent_expression_p) on macro function + user defined literal
  2015-08-03 12:40 [Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal tower120 at gmail dot com
                   ` (2 preceding siblings ...)
  2015-08-03 13:59 ` tower120 at gmail dot com
@ 2015-08-19  9:37 ` mpolacek at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-08-19  9:37 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

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

--- Comment #4 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Fixed in r220656.


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

end of thread, other threads:[~2015-08-19  9:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 12:40 [Bug c++/67100] New: ICE(in type_dependent_expression_p) on macro function + user defined literal tower120 at gmail dot com
2015-08-03 12:42 ` [Bug c++/67100] " tower120 at gmail dot com
2015-08-03 13:34 ` trippels at gcc dot gnu.org
2015-08-03 13:59 ` tower120 at gmail dot com
2015-08-19  9:37 ` mpolacek 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).