This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 243171 - No code completion for auto variable
Summary: No code completion for auto variable
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Code Completion (show other bugs)
Version: 8.0.1
Hardware: PC Windows 7 x64
: P2 normal (vote)
Assignee: petrk
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-22 10:36 UTC by VaderZ
Modified: 2014-04-28 13:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
no auto completion (23.10 KB, image/png)
2014-03-28 18:39 UTC, andreroquem
Details
auto completion ok for shared_ptr without auto (32.06 KB, image/png)
2014-03-28 18:39 UTC, andreroquem
Details

Note You need to log in before you can comment on or make changes to this bug.
Description VaderZ 2014-03-22 10:36:46 UTC
No code completion in Dev 201403030001/201403210001 for auto variable which source is (?)dynamic(?)

struct MyClass{
    void foo(){}
};

int main() {
    auto varCorrect0 = MyClass();
    auto varCorrect1 = &varCorrect0;
    auto varIncorrect0 = new MyClass();
    auto varIncorrect1 = std::make_shared(new MyClass());
    
    varCorrect0.foo();        //OK
    varCorrect1->foo();       //Note: even if varCorrect1 is a ptr it works just fine
    varIncorrect0->foo();     //Unable to resolve identifier foo
    varIncorrect1->foo();     //Unable to resolve identifier foo 
    
    std::vector<MyClass> vec(3);
    for (auto varInteresting0 : vec) {
        varInteresting0 ->foo(); //In 201403030001 were incorrect but got fixed until 201403210001
    }
    return 0;
}

The bug is maybe a variant(!) of #214111
Comment 1 andreroquem 2014-03-28 18:38:12 UTC
I got this problem too, was about to create a new bug. My test code is:

#include <iostream>
#include <memory>

class Test {
public:
    void doSomething(void) {
        std::cout << "Hi, there" << std::endl;
    }
};

int main(int argc, char **argv)
{
    auto i = 1;
    auto x = new int(2);
    i++;
    auto ip = std::shared_ptr<int>(x);
    *ip = *ip + 4;
    std::cout << "i: " << i << "ip: " << *ip << std::endl;
    
    Test *t = new Test();
    t->doSomething();
    auto tp = std::shared_ptr<Test>(t);
    tp->doSomething();  /* No autocompletion in this case */
    std::shared_ptr<Test> tp2 = std::shared_ptr<Teste>(t);
    tp2->doSomething();
}

I'll attach some screenshoots too.
Comment 2 andreroquem 2014-03-28 18:39:13 UTC
Created attachment 146392 [details]
no auto completion
Comment 3 andreroquem 2014-03-28 18:39:44 UTC
Created attachment 146393 [details]
auto completion ok for shared_ptr without auto
Comment 4 petrk 2014-04-10 16:41:53 UTC
Fixed in http://hg.netbeans.org/cnd-main/rev/bde743ff9c12

Btw, the first test case is not compilable - std::make_shared should be explicitely instantiated with parameter MyClass.
==============================================================================
#include <memory>
#include <vector>

struct MyClass{
    void foo(){}
};

int main() {
    auto varCorrect0 = MyClass();
    auto varCorrect1 = &varCorrect0;
    auto varIncorrect0 = new MyClass();
    auto varIncorrect1 = std::make_shared<MyClass>(MyClass());
    
    varCorrect0.foo();   
    varCorrect1->foo(); 
    varIncorrect0->foo();  
    varIncorrect1->foo();   
    
    std::vector<MyClass> vec(3);
    for (auto varInteresting0 : vec) {
        varInteresting0.foo(); 
    }
    return 0; 
}  
===============================================================================
Comment 5 Quality Engineering 2014-04-18 02:42:39 UTC
Integrated into 'main-silver', will be available in build *201404180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/bde743ff9c12
User: Petr Kudryavtsev <petrk@netbeans.org>
Log: Fixed #243171 - No code completion for auto variable
Comment 6 soldatov 2014-04-22 13:41:00 UTC
verified in trunk build 201404220001
Comment 7 Quality Engineering 2014-04-24 02:04:37 UTC
Integrated into 'releases/release80', will be available in build *201404240045* or newer. Wait for official and publicly available build.

Changeset: http://hg.netbeans.org/releases/rev/736c3c0dbb67
User: Petr Kudryavtsev <petrk@netbeans.org>
Log: Fixed #243171 - No code completion for auto variable
(transplanted from bde743ff9c12fe1d5a536d6ad50764ea93420773)
Comment 8 soldatov 2014-04-28 13:02:15 UTC
verified in NetBeans 8.0 patch1 build