public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64924] New: Callback function passed as a parameter with typename declaration produces an ICE.
@ 2015-02-03 18:08 martin.boretto at tallertechnologies dot com
  2015-02-03 18:17 ` [Bug c++/64924] " trippels at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: martin.boretto at tallertechnologies dot com @ 2015-02-03 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64924
           Summary: Callback function passed as a parameter with typename
                    declaration produces an ICE.
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: martin.boretto at tallertechnologies dot com

Created attachment 34659
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34659&action=edit
Preprocessed source stored

The code below produces an ICE error:


// --------------------------------------------------
template<typename T>
class PP
{
public:
    /**
    * @brief Constructor with instance and callback function.
    */
    PP(T* instance, typename PP::CallbackFunction callbackFunction);

private:
    /**
    * @brief callback function.
    */
    typedef void (T::*CallbackFunction)(void);
};

template<typename T>
PP<T>::PP(T* instance, CallbackFunction callbackFunction)
{}


// --------------------------------------------------
class JJ
{
public:
    /**
    * Constructor class.
    */
    JJ():
        _attr(this, &JJ::m)
    {}

    /**
    * @brief Call back function.
    */
    void m()
    {}

private:
    /** @brief Class attribute instantiated with "this" class. */
    PP<JJ> _attr;
};

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

int main(int argc, char const *argv[])
{
    JJ juancillo;
    return 0;
}


Execution:

g++ -std=c++11 -Wall -Wextra -ansi -pedantic-errors example.cpp -o example


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

* [Bug c++/64924] Callback function passed as a parameter with typename declaration produces an ICE.
  2015-02-03 18:08 [Bug c++/64924] New: Callback function passed as a parameter with typename declaration produces an ICE martin.boretto at tallertechnologies dot com
@ 2015-02-03 18:17 ` trippels at gcc dot gnu.org
  2020-03-12 18:52 ` mpolacek at gcc dot gnu.org
  2021-08-08  8:48 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: trippels at gcc dot gnu.org @ 2015-02-03 18:17 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-02-03
                 CC|                            |trippels at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to fail|                            |4.8.4, 4.9.2, 5.0

--- Comment #1 from Markus Trippelsdorf <trippels at gcc dot gnu.org> ---
clang and the intel compiler reject the testcase.
All supported gcc versions crash.

markus@x4 /tmp % clang++ -std=c++11 te.cpp
te.cpp:9:34: error: no type named 'CallbackFunction' in 'PP<T>'
    PP(T* instance, typename PP::CallbackFunction callbackFunction);
                    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
te.cpp:19:8: error: out-of-line definition of 'PP<T>' does not match any
declaration in 'PP<T>'
PP<T>::PP(T* instance, CallbackFunction callbackFunction)
       ^~
2 errors generated.

markus@x4 /tmp % icpc -std=c++11 te.cpp
te.cpp(19): error: no instance of overloaded function "PP<T>::PP" matches the
specified type
  PP<T>::PP(T* instance, CallbackFunction callbackFunction)
         ^

te.cpp(9): error: class "PP<JJ>" has no member "CallbackFunction"
      PP(T* instance, typename PP::CallbackFunction callbackFunction);
                                   ^
          detected during instantiation of class "PP<T> [with T=JJ]" at line 42

compilation aborted for te.cpp (code 2)

markus@x4 /tmp % g++ -std=c++11 te.cpp
te.cpp:19:57: internal compiler error: Segmentation fault
 PP<T>::PP(T* instance, CallbackFunction callbackFunction)
                                                         ^
0xc96d4f crash_signal
        ../../gcc/gcc/toplev.c:383
0xeeed10 strip_array_types(tree_node*)
        ../../gcc/gcc/tree.c:8025
0x73c1e8 cp_type_quals(tree_node const*)
        ../../gcc/gcc/cp/typeck.c:8916
0x73c2b8 original_type
        ../../gcc/gcc/cp/typeck.c:259
0x7431d8 merge_types(tree_node*, tree_node*)
        ../../gcc/gcc/cp/typeck.c:752
0x743313 merge_types(tree_node*, tree_node*)
        ../../gcc/gcc/cp/typeck.c:797
0x7438fb commonparms
        ../../gcc/gcc/cp/typeck.c:243
0x7438fb merge_types(tree_node*, tree_node*)
        ../../gcc/gcc/cp/typeck.c:863
0x743ac3 merge_types(tree_node*, tree_node*)
        ../../gcc/gcc/cp/typeck.c:898
0x62c083 duplicate_decls(tree_node*, tree_node*, bool)
        ../../gcc/gcc/cp/decl.c:1975
0x590a5c grokfndecl
        ../../gcc/gcc/cp/decl.c:8035
0x639dbd grokdeclarator(cp_declarator const*, cp_decl_specifier_seq*,
decl_context, int, tree_node**)
        ../../gcc/gcc/cp/decl.c:10992
0x63b466 start_function(cp_decl_specifier_seq*, cp_declarator const*,
tree_node*)
        ../../gcc/gcc/cp/decl.c:13730
0x72798c cp_parser_function_definition_from_specifiers_and_declarator
        ../../gcc/gcc/cp/parser.c:23342
0x72798c cp_parser_init_declarator
        ../../gcc/gcc/cp/parser.c:17064
0x72832c cp_parser_single_declaration
        ../../gcc/gcc/cp/parser.c:23801
0x7285b2 cp_parser_template_declaration_after_export
        ../../gcc/gcc/cp/parser.c:23592
0x731ab9 cp_parser_declaration
        ../../gcc/gcc/cp/parser.c:11336
0x731baa cp_parser_declaration_seq_opt
        ../../gcc/gcc/cp/parser.c:11258
0x731ebf cp_parser_translation_unit
        ../../gcc/gcc/cp/parser.c:4109
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug c++/64924] Callback function passed as a parameter with typename declaration produces an ICE.
  2015-02-03 18:08 [Bug c++/64924] New: Callback function passed as a parameter with typename declaration produces an ICE martin.boretto at tallertechnologies dot com
  2015-02-03 18:17 ` [Bug c++/64924] " trippels at gcc dot gnu.org
@ 2020-03-12 18:52 ` mpolacek at gcc dot gnu.org
  2021-08-08  8:48 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-03-12 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Still ICEs with GCC 10.

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

* [Bug c++/64924] Callback function passed as a parameter with typename declaration produces an ICE.
  2015-02-03 18:08 [Bug c++/64924] New: Callback function passed as a parameter with typename declaration produces an ICE martin.boretto at tallertechnologies dot com
  2015-02-03 18:17 ` [Bug c++/64924] " trippels at gcc dot gnu.org
  2020-03-12 18:52 ` mpolacek at gcc dot gnu.org
@ 2021-08-08  8:48 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-08  8:48 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |accepts-invalid

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Short testcase:
template<typename T>
struct PP
{
    PP(typename PP::gg n);
        typedef void (T::*gg)(void);
};
template<typename T>
PP<T>::PP(gg n) {}
---- CUT ----
We also accept invalid code too:
template<typename T>
struct PP
{
    PP(typename PP::gg n);
        typedef int gg;
};
template<typename T>
PP<T>::PP(gg n) {}

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

end of thread, other threads:[~2021-08-08  8:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-03 18:08 [Bug c++/64924] New: Callback function passed as a parameter with typename declaration produces an ICE martin.boretto at tallertechnologies dot com
2015-02-03 18:17 ` [Bug c++/64924] " trippels at gcc dot gnu.org
2020-03-12 18:52 ` mpolacek at gcc dot gnu.org
2021-08-08  8:48 ` pinskia 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).