Bug 29824 - std::string() causes assignment errors
Summary: std::string() causes assignment errors
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-11-14 05:17 UTC by Daniel Dilts
Modified: 2006-11-14 05:21 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Dilts 2006-11-14 05:17:27 UTC
#include <string>

int main()
{
    std::string a();
    a="alskdfjasdj";
    return 0;
}

output:
test.cpp: In function int main():
test.cpp:6: error: assignment of function std::string a()
test.cpp:6: error: cannot convert const char [12] to std::string ()() in assignment

#include <string>

int main()
{
    std::string a("");
    a="alskdfjasdj";
    return 0;
}

This compiles.

My understanding is that std::string a() and std::string a("") should have exactly the same result, such that the assignment of the c-string should be valid in both situations.
Comment 1 Daniel Dilts 2006-11-14 05:18:58 UTC
I neglected to comment that the command line was:
g++ test.cpp
Comment 2 Andrew Pinski 2006-11-14 05:21:33 UTC
    std::string a();

This declares a function that returns std::string.

This is what the C++ standard says how to resolve this ambigous statement.