Bug 69392 - G++ can't capture 'this' pointer to templated type using init-capture
Summary: G++ can't capture 'this' pointer to templated type using init-capture
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 5.1.0
: P3 normal
Target Milestone: 6.0
Assignee: Jason Merrill
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2016-01-20 16:48 UTC by Kyle J Strand
Modified: 2016-01-22 21:07 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-01-21 00:00:00


Attachments
Tarball with source (with comments), preprocessed source, and compiler output (1.47 KB, application/x-gzip)
2016-01-20 16:48 UTC, Kyle J Strand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle J Strand 2016-01-20 16:48:38 UTC
Created attachment 37409 [details]
Tarball with source (with comments), preprocessed source, and compiler output

G++ erroneously fails to deduce the type of the `this` pointer inside a template-class member function when using init-capture to copy `this` into a lambda.

My GCC version is 5.1.0 on an x86_64 architecture. My OS is Debian 8.

More information, including a comparison to Clang++ and a list of variations that do or do not work, is available on this StackOverflow question: http://stackoverflow.com/q/34889310/1858225
Comment 1 Jason Merrill 2016-01-22 20:37:02 UTC
Author: jason
Date: Fri Jan 22 20:36:30 2016
New Revision: 232746

URL: https://gcc.gnu.org/viewcvs?rev=232746&root=gcc&view=rev
Log:
	PR c++/69392
	* lambda.c (lambda_capture_field_type): Handle 'this' specially
	for init-capture, too.

Added:
    trunk/gcc/testsuite/g++.dg/cpp1y/lambda-init14.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/lambda.c
Comment 2 Kyle J Strand 2016-01-22 20:51:23 UTC
(In reply to Jason Merrill from comment #1)
> Log:
> 	PR c++/69392
> 	* lambda.c (lambda_capture_field_type): Handle 'this' specially
> 	for init-capture, too.
> 

What special handling is done for 'this'?
Comment 3 Jason Merrill 2016-01-22 21:07:37 UTC
(In reply to Kyle J Strand from comment #2)
> What special handling is done for 'this'?

Basically, we treat it as non-dependent.