Skip to content

Conversation

denis-sh
Copy link
Contributor

In the name of God, the King, and Walter I managed to release it.

This is the time D becoming a language with working emplace for structs (sorry, not for classes now).

Now specialization for struct works this way:

T t = args[0];

if the latter compiles and works like

T t = T(args);

otherwise.

And specialization for static array works this way:

T t = arg;

Note:

I have almost exhausted my power of apprehension so some bugs may be missed.

Requires: #776, #952, #928, #948.

@denis-sh
Copy link
Contributor Author

OK, it isn't lucky enough to pass autotester. At least it compiles - already not bad.
As you probably already guessed I'm not going to debug it in a state when required pulls aren't merged.

@braddr
Copy link
Member

braddr commented Nov 16, 2012

It's not only not passing, it's also causing grief due to tests hanging (a problem with the test system, I admit, but generally not a huge issue). One stack trace from glibc detecting double frees:

*** glibc detected *** generated/linux/debug/32/unittest/std/algorithm: double free or corruption (fasttop): 0x09bf72a8 ***
======= Backtrace: =========
/lib/libc.so.6(+0x6eab1)[0x23dab1]
generated/linux/debug/32/unittest/std/algorithm(_D3std9container47__T5ArrayTS3std8typecons14__T5TupleTkTkZ5TupleZ5Array7Payload6__dtorMFZv+0x5e)[0x82e7b3a]
generated/linux/debug/32/unittest/std/algorithm(_D6object15TypeInfo_Struct7destroyMxFPvZv+0x12)[0x82f595e]
generated/linux/debug/32/unittest/std/algorithm(_D6object91__T7destroyTS3std9container47__T5ArrayTS3std8typecons14__T5TupleTkTkZ5TupleZ5Array7PayloadZ7destroyFKS3std9container47__T5ArrayTS3std8typecons14__T5TupleTkTkZ5TupleZ5Array7PayloadZv+0x1d)[0x82ead7d]
generated/linux/debug/32/unittest/std/algorithm(_D3std8typecons137__T10RefCountedTS3std9container47__T5ArrayTS3std8typecons14__T5TupleTkTkZ5TupleZ5Array7PayloadVE3std8typecons24RefCountedAutoInitialize0Z10RefCounted6__dtorMFZv+0x48)[0x82e9cc4]
generated/linux/debug/32/unittest/std/algorithm(_D3std9container47__T5ArrayTS3std8typecons14__T5TupleTkTkZ5TupleZ5Array11__fieldDtorMFZv+0x11)[0x82e9e21]
generated/linux/debug/32/unittest/std/algorithm(_D3std9algorithm19__unittestL9470_142FZv+0x106)[0x823c686]
generated/linux/debug/32/unittest/std/algorithm(_D3std9algorithm9__modtestFZv+0x23d)[0x82f41f9]
generated/linux/debug/32/unittest/std/algorithm(_D4core7runtime18runModuleUnitTestsUZb16__foreachbody319MFKPS6object10ModuleInfoZi+0x24)[0x8310070]
generated/linux/debug/32/unittest/std/algorithm(_D2rt5minfo17moduleinfos_applyFMDFKPS6object10ModuleInfoZiZi+0x3c)[0x82fc63c]
generated/linux/debug/32/unittest/std/algorithm(runModuleUnitTests+0x87)[0x830ff87]
generated/linux/debug/32/unittest/std/algorithm(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi6runAllMFZv+0x20)[0x82f8c38]
generated/linux/debug/32/unittest/std/algorithm(_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZi7tryExecMFMDFZvZv+0x18)[0x82f8720]
generated/linux/debug/32/unittest/std/algorithm(_d_run_main+0x121)[0x82f86f1]
generated/linux/debug/32/unittest/std/algorithm(main+0x14)[0x82f85c4]
/lib/libc.so.6(__libc_start_main+0xe6)[0x1e5ce6]
generated/linux/debug/32/unittest/std/algorithm[0x8215041]

Would you please either close this request until it's fixed or get it working? What platform did you test it on before submitting the pull?

@denis-sh
Copy link
Contributor Author

Would you please either close this request until it's fixed or get it working?

I will rebase instead.

What platform did you test it on before submitting the pull?

Windows XP 32 bit, an "dirEntry" test failed at runtime and I had no idea why.



// Used in `emplace`
private template _implicitlyConvertibleDim(From, To)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is used only inside emplace, it would be simpler to simply define it inside emplace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impossible. It is used in _initializeFrom and emplace overload for a static array.

@denis-sh
Copy link
Contributor Author

To @andralex:

s/convertable/convertible/

Done.

This would be replaced by forward.

Done.


should use a different symbol instead of l

It is unrelated to this pull. First commit of this pull is Finally fix emplace.
All commits before are from pull #896 as it this pull is based on that one an I don't update commits from other pull so ignore it. Once #896 will be merged, I will delete these commits from this pull and rebase.

Using `scoped` with nested class compiles but shouldn't as it results in undefined behavior.
@dnadlinger
Copy link
Contributor

I'd really like to see a solid emplace implementation. But as long as this pull request deliberately relies on code that has been previously rejected, it is just clogging up the auto tester for no good reason (ArrayElementType from #776, see the comments there).

Please consider turning this into a nicely self-contained patch (you could add any templates you need for the implementation as private helpers), and re-open the pull request after that.

@dnadlinger dnadlinger closed this Mar 23, 2013
@monarchdodra
Copy link
Collaborator

I'd really like to see a solid emplace implementation.

I have also submitted an emplace fix: #1082.

It does not benefit from denis' templated functions ("callPostblits"), but has the advantage of being stand alone.

Did you see it? Review?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants